If you use a string variable in ng-show or ng-hide, you can check the variable as shown below:
Template:
<div ng-controller="MyCtrl"> <div ng-show="displayed != null">test1</div> <div ng-show="displayed == 'false'">test2</div> </div>
Controller:
var myApp = angular.module('myApp', []); myApp.controller('MyCtrl', function ($scope, $parse) { $scope.displayed = 'false'; });
now both divs will display correctly
If you use a boolean variable in ng-show or ng-hide, you can check the variable as shown below:
Template:
<div ng-controller="MyCtrl"> <div ng-show="displayed">test1</div> <div ng-show="!displayed">test2</div> </div>
Controller:
var myApp = angular.module('myApp', []); myApp.controller('MyCtrl', function ($scope, $parse) { $scope.displayed = false; });
for above boolean condition, the first div will not be shown, and the second div will be shown.
source share