可以绑定一个ng-click
事件,所有这三个按钮,通过标识的功能(即按钮的id
。然后你的函数将一个变量绑定到的范围,然后你可以使用以确定是否ng-disabled
应进行或不
例如,在你的控制器,你将有类似的东西:
$scope.selectedButton;
$scope.selectButton = function(id) {
$scope.selectedButton = id;
}
然后,在你的HTML,你将修改它拿在ng-click
和ng-disabled
考虑上述。
<html ng-app ng-controller="SomeController">
<button ng-disabled="selectedButton && selectedButton != 'abc'" ng-click="selectButton('abc')">abc</button>
<button ng-disabled="selectedButton && selectedButton != 'def'" ng-click="selectButton('def')">def</button>
<button ng-disabled="selectedButton && selectedButton != 'ghi'" ng-click="selectButton('ghi')">ghi</button>
</html>
笔记,检查是否selectedButton和selectedButton不等于foo
的逻辑,是确定按钮已经被选择,因此该变量被设置为范围。
谢谢大家。我喜欢这个答案。 – Deke