If you use routes you can run some logic on each route change in the resolve
block in the routeprovider.
In the example below I'm using a custom SystemService service that stores the location and in turn broadcasts an event on $rootScope. In this example the navigation is outside of the views managed by the routed controllers and has its own controller:
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/welcome.html',
controller: 'WelcomeCtrl',
resolve: {
load: function(SystemService){
SystemService.fireNavEvent({showNav:false,location:'/'});
}
}
}).
when('/other', {
templateUrl: 'partials/other.html',
controller: 'ElseCtrl',
resolve: {
load: function(SystemService){
SystemService.fireNavEvent({showNav:true,location:'/other'});
}
}
}).
otherwise({
redirectTo: '/'
});
}]);
// in SystemServce:
function fireNavEvent(obj){
this.showNav = obj.showNav;
$rootScope.$broadcast('navEvent',obj);
}
// then in the navigtion controller:
$scope.$on("navEvent", function(evt,args){
$scope.showNav = SystemService.showNav;
// also some logic to set the active nav item based on location
});
There are other ways to achieve this, for example you could just broadcast the navigation change on $rootScope
directly from the routes config.
You could also inject $location into your controller and set the visibility based on that.