我有簡單的控制器代碼:爲什麼範圍值不能通過使用「切換」技術從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你的問題很好:) –