禁用 ng 重复列表中的链接



我使用ng-repeat将一组值显示为超链接,从而进一步在下一个DIV中打开相关数据。现在,当我单击链接时,在相应的div中加载数据后,如何禁用单击的链接?

angular.module('app', []).controller('ctrl', function($scope){
$scope.items = [
{name:'First', descr:'First Description'},
{name:'Second', descr:'Second Description'},
{name:'Third', descr:'Third Description'}
]
var visited = [];
$scope.act = function(item){
if(visited.indexOf(item.name) == -1){
item.dis = true;
$scope.active = item;
visited.push(item.name);
}
}
})
.dis {
color: currentColor;
cursor: not-allowed;
opacity: 0.5;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js">
</script>
<div ng-app='app' ng-controller='ctrl'>
<a ng-class='{dis:x.dis}' ng-repeat-start='x in items' href='#' ng-click='act(x)'>
{{x.name}}  
</a>
<br ng-repeat-end>
<div>
{{active.descr}}
</div>
</div>

最新更新