我有简单的控制器代码:为什么范围值不能通过使用“切换”技术从HTML更改?
JS
$scope.showErrorAlert = false;
$scope.switchBool = function(value) {
value = !value;
};
HTML
<div class="alert alert-error" ng-show="showErrorAlert">
<button type="button" class="close" data-ng-click="switchBool(showErrorAlert)" >×</button>
<strong>Error!</strong> {{errorTextAlert}}
</div>
从代码片段你可以看到,我试图改变$scope.showErrorAlert
值。
但是它不起作用,value
更改但不是showErrorAlert
。
有人可以告诉我为什么以及如何使它工作吗?
谢谢
+1你的问题很好:) –