ビュー内のすべてのチェックボックスを選択/選択解除できる機能を設定しようとしました。しかし、それはまったく動かないようです。私が欠けているものはありますか?AngularJSで機能しないすべての機能をチェック/チェック解除する
私の実装は次の通りです:http://jsfiddle.net/deeptechtons/TKVH6/。
detail.html
<li class="item item-checkbox">
All Services<br>
<label class="checkbox">
<input type="checkbox" ng-model="selectedAll" ng-click="checkAll()" ng-model="selectedAll">
</label>
</li>
<li class="item item-checkbox" ng-repeat="e in inventory">
{{ e.title }}<br>
<span class="grey-text">£{{ e.price | number: 2 }}</span>
<label class="checkbox">
<input type="checkbox" ng-model="item.selected">
</label>
</li>
controller.js
$scope.checkAll = function() {
if ($scope.selectedAll) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.inventory, function (item) {
item.selected = $scope.selectedAll;
});
};
問題を複製するプランナーデモを作成します。スコープのコンテキストがそれ以上なければ、問題を解決することは困難です。常に*常に常に 'ng-model'にドットを入れ、メインのチェックボックスに重複した属性があることに注意してください。 – charlietfl