我已使用 $(".CLASS").filter(function(i, e){
return (e.parentNode.id != "ID");
}
将一组值显示为超链接,这将进一步打开下一个DIV中的相关数据。现在当我点击链接时,在相应的div中加载数据后,如何禁用点击的链接?
答案 0 :(得分:0)
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>
&#13;