以下のコードでは、
<label>
<input type="checkbox" ng-model="showList">
Show unordered list
</label>
<ng-include src="getList()"></ng-include>
$scope.getList()
$scope.showList
チェックまたはチェック解除による変更時に呼び出されます。ここで$scope.showList
、として使用されます。
app3.controller('gListCtrl', function($scope){
$scope.getList = function(){
return $scope.showList ? "ulgrocerylist.html" : "grocerylist.html";
};
});
$scope.getList()
の状態が変化したときに呼び出されるのはなぜ$scope.showList
ですか?
同様のコード、
<p>
<button ng-disabled="disableButton">Button</button>
</p>
<p>
<input type="checkbox"
ng-model="disableButton">DisableButton
</p>
disableButton
状態が変化しているため、双方向バインディングのためにボタンが無効または有効になるため、私には理にかなっています。