在下面的代码中,
<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状态正在改变,所以按钮由于两种方式绑定而被禁用或启用。