2014-09-25 63 views
0
<span class="column__list--total fa" ng-class="{'fa-check': skill.done == 1, 'fa-times red': skill.done == 0}" ng-click="skill.disabled || toggleSkill(skill.id, person.id)" ng-hide="$root.user[0].auth == 2"></span> 

<span class="column__list--total fa" ng-class="{'fa-check': skill.done == 1, 'fa-times red': skill.done == 0}" ng-show="$root.user[0].auth == 2"></span> 

在我使用的是上面的那一刻NG点击,他们同样相同的,但人会使用ng-hide当一个变量等于2AngularJS禁用当一个变量等于

的原因是我想被隐藏在元素上禁用ng-click

我需要保持它作为两个独立的元件或者是有可能禁用ng-click$root.user[0].auth == 2

回答

2

你已经在你的ng-click的条件,为什么不添加其他?

ng-click="$root.user[0].auth == 2 || skill.disabled || toggleSkill(skill.id, person.id)"

0

你可以做return;toggleSkill()执行任何其他代码之前。

$scope.toggleSkill = function(skill.id, person.id) { 
    if ($root.user[0].auth == 2) { 
     return; 
    } 

    // Rest of your code 
}