hide content in specific controller in angular js

141 Views Asked by At

In my website i have navigation bar in index page ( index controller).When i click the login button the state and controller will change to login controller. And i want to hide the navigation bar in login controller.

I don't want to hide navigation bar based on state change or route change.I want to hide navigation bar in login controller controller.

can you please help.thanks in advance.

2

There are 2 best solutions below

0
On

Javascript

 var pages = ['/'];
$rootScope.$on('$locationChangeSuccess', function() {
  var $$route = $route.current.$$route;
  $scope.contentShow = $$route && pages.indexOf($$route.originalPath) < 0;
});

HTML

<div ng-hide="contentShow">Content</div>
0
On

In angular you can hide content in various ways for example:

<div ng-if="showMe">shown if showMe true</div> ( creates subscope, not visible in dom)
<div ng-hide="hideMe">hidden if hideMe true</div> ( no subscope, visible in dom, but not visible for user)
<div ng-class="{'displayNoneClass': hideMe}"> hidden if hideMe true</div> ( no subscope, adding just class with display: none; property
<div ng-style="hideMe"> add style to hideMe like hideMe='{display: none}' which will be embedded into inline style</div>

I have no other ideas...