我有两个屏幕出现在一个区域,我正在使用ng-hide / ng-show !!
我的代码是:
控制器内部
$scope.grid1show = 'true' // intially this grid will shown on page load
$scope.grid2show = 'false' // Intially this grid is hide on page load
// Function
$scope.showGrid = function(){
$scope.grid1show = 'false';
$scope.grid2show = 'true';
console.log ("==after==" +$scope.grid1show );
console.log ("===after==="+ $scope.grid2show );
};
在我的HTML
中<div ng-show="grid1show"> Shown this div initially
<span ng-click="showGrid2()">Click for grid2</span> // IT should fire function which should show grid2 and hide grid1
</div>
<div ng-show="grid2show"> Hide this div intially </div>
但是虽然在控制台中,它正在改变,但实际上并没有隐藏并显示特定的div !!
这里有什么我想念的吗?
答案 0 :(得分:1)
为什么要将值存储为字符串?
$scope.grid1show = 'false';
$scope.grid2show = 'true';
它们不应该是布尔值吗?
$scope.grid1show = false;
$scope.grid2show = true;