[英]Checkbox: make ng-click run when checked by ng-checked/ng-model
所以我有這個:
<tbody ng-repeat="x in keys">
<tr>
<td>
<input type="checkbox" ng-model="master">
{{ x.key }}
</td>
<td ng-repeat="lang in languages">
{{ getTranslation(x,lang.id) }}
<input type="checkbox" ng-click="toggleSelection(x,lang.id)" ng-model="master">
</td>
</tr>
</tbody>
我的問題是,如果我選中第一個復選框,則無需運行ng-click即可選中其他復選框。 通過第一個復選框選中復選框時,如何使ng-click運行? 我也嘗試了ng-change。
“ ng-change”指令應該可以。 試試這個例子:
<script>
angular.module('changeExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.counter = 0;
$scope.change = function() {
$scope.counter++;
};
}]);
</script>
<div ng-controller="ExampleController">
<input type="checkbox" ng-model="confirmed" ng-change="change()" id="ng-change-example1" />
<input type="checkbox" ng-model="confirmed" id="ng-change-example2" />
<label for="ng-change-example2">Confirmed</label><br />
<tt>debug = {{confirmed}}</tt><br/>
<tt>counter = {{counter}}</tt><br/>
</div>
你可以在這里找到
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.