我想根據點擊來隱藏/顯示div。當頁面加載div被隱藏時,這是預期的行爲,但我必須點擊兩次才能讓它開始切換。我在這裏錯過了什麼?ng-show需要兩次點擊才能開始切換
這是我的代碼
<a href ng-click="ShowOrHide('01')" class="list-group-item">Night 1</a> <div ng-show="showNight">{{night}}</div>
,這是角模塊
var MyApp = angular.module("MyModule", []);
MyApp .controller("MyController", function ($scope){
$scope.test = "This is from angular";
$scope.showNight = "false";
$scope.ShowOrHide = function(night){
$scope.night = "night " + night;
$scope.showNight = !$scope.showNight;
};
});
false和「false」不一樣 –