Created
June 29, 2015 23:18
-
-
Save MehulATL/e5b7d7d849c34a1250cd to your computer and use it in GitHub Desktop.
declare view title in ui.router state declaration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.run(function($rootScope, $injector, $state, $stateParams) { | |
$rootScope.$state = $state; | |
$rootScope.$stateParams = $stateParams; | |
$rootScope.$title = function() { | |
if (angular.isFunction($state.current.title)) { | |
return $injector.invoke($state.current.title, $rootScope, { | |
$scope: $rootScope, | |
$currentState: $state.current | |
}); | |
} else if (angular.isString($state.current.title)) { | |
return $state.current.title; | |
} else { | |
return 'Hello World'; | |
} | |
}; | |
}) | |
// ng-bind the <title> to $title() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment