我在控制器中有一个条件。如果条件返回true,则必须禁用所有链接和ng-click
s
我们该怎么做:-
Controller : $scope.disableActions = true;
在HTML中
<button type="button" ng-click="ignoreAndRedisplay()" ng-disabled="disableActions">OpenClick</button>
因此,通过这样做,我必须到处写ng-disabled="disableActions"
,这将是多余的,如何改善n
按钮和链接的数量?
在这种情况下,我建议您将所有按钮放到单个按钮上fieldset
并套用ng-disabled
在该按钮上,如果表达式计算fieldset
为该字段集内的控件将自动获取disabled
ng-disabled
true
<fieldset ng-disabled="disableActions">
<button type="button" ng-click="ignoreAndRedisplay()">OpenClick</button>
<button type="button" >Some Other button</button>
<button type="button" >One more button</button>
...
</fieldset>
如注释中所述,OP要求禁用anchor
标签。基本上,您不能禁用anchor
标签。您可以尝试以下技巧以使其正常运行。
fieldset[disabled] a {
pointer-events: none;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句