I'm using Angular's UI-Router as shown below to do URL-routing in my web-app as shown below:
$stateProvider.state('myState1', { url: '/state1', templateUrl: 'state1.html', controller: 'MyState1Ctrl' }); $stateProvider.state('myState2', { url: '/state2', templateUrl: 'state2.html', controller: 'MyState2Ctrl' }); Within each of the two template files state1.html, state2.html, I have my navigation bar directive: <myapp-navigation-bar></myapp-navigation-bar>. Here is the navigation bar's controller:
raptorApp.controller('NavigationCtrl', function($scope){ var self = this; $scope.$watch(function() {return "something";}, function (objVal) { console.log('Hello from NavigationCtrl!'); },true); }); But I want the navigation bar to behave differently based on weather it is in myState1 or myState2. How can I detect from within NavigationCtrl which state it is in?