angular ng-href小测试

<div ng-controller="footController">
<ul >
<a style="display: block;" ng-repeat="footItem in footItems"ng-click='click($index)' ng-class="{action: $index==classes}" ng-href="{{footItem.href}}">{{footItem.name}}</a>
</ul>
</div>

.controller('footController', function($scope) {
$scope.footItems = [{
name: 'baidu',
href:'http://www.baidu.com'
}, {
name: 'google',
href:'http://www.google.com'
},{
name:'qq',
href:'http://qq.com'
},{
name:"soso",
href:'http://soso.com'
}]
$scope.click = function(classes){
$scope.classes=classes
}
})

 

实际效果,会放在导航栏上,点击对应的导航,会跳转到对应的网站

如果不要整页跳转,可以使用路由和$loaction 切换视图

会陆续更新

posted @ 2016-04-26 15:50  $button  阅读(371)  评论(0编辑  收藏  举报