我想在HTML中更改 <div ng-repeat="post in posts">
<h2>
{{post.title}}
<a ng-click="editPost(post._id)" class="pull-right"><span class="glyphicon glyphicon-pencil"></span></a>
<a ng-click="deletePost(post._id)" class="pull-right"><span class = "glyphicon glyphicon-remove"></span></a>
</h2>
<em>{{post.posted}}</em>
<p>{{post.body}}</p>
</div>
的值以打开另一个html文件。
{{1}}
http://codepen.io/harvey89/pen/NpaWBE
.html文件的位置:
答案 0 :(得分:2)
你可以这样做,
<a ng-click="redirect()">{{ post.title }} </a>
在控制器中:
$scope.redirect = function(){
window.location = "#/titleDetails.html";
}
答案 1 :(得分:1)
您可以在帖子中为目标网址添加一个属性
<a href="{{'#'+post.url}}">{{post.title}}</a>
如果您确定网址,则可以自行输入网址
<a href="#destinationpage">{{post.title}}</a>
答案 2 :(得分:0)
试试这个:
<a href="#" ng-click="ClickMeToRedirect()">{{ post.title }}</a>
var app = angular.module('urlApp', []);
app.controller('urlCtrl', function ($scope, $log, $window) {
$scope.ClickMeToRedirect = function () {
var url = "http://" + $window.location.host + "/titleDetails.html";
$log.log(url);
$window.location.href = url;
};
});
OR
var url = "#/titleDetails.html";