I'd like to hide navBar if i'm on some locations. A have the index page:
<navbar ng-show="showNavbar"></navbar>
<div ng-view></div>
with js:
scope.showNavbar=(window.location.hash == '#/login');
I tried to put a location checker to the mainCtrl, but than, it wasn't check the location just once. After that, i put into my goClick directive
.directive( 'goClick', function ( $location) {
return function ( scope, element, attrs ) {
var path;
attrs.$observe( 'goClick', function (val) {
path = val;
});
scope.showNavbar=(window.location.hash == '#/login');
element.bind( 'click', function () {
scope.$apply( function () {
$location.path( path );
});
});
};
});
it checked it, but couldn't pass the value neither the html page nor the Ctrl.
change
<navbar ng-show="showNavbar"></navbar>
to
<navbar ng-show="showNavbar()"></navbar>
and controller
scope.showNavbar = function(){
if($location.path() =='/login'){
return true;
}else{
return false;
}
}