ng-hide / ng-show无法用ng-click调用的功能工作



我有两个屏幕要出现在一个区域,我正在使用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 !!

我这里有什么我缺少的吗?

为什么将值存储为字符串?

$scope.grid1show = 'false';
$scope.grid2show = 'true';

他们不应该是布尔人吗?

$scope.grid1show = false;
$scope.grid2show = true;

最新更新