I try to put action
parameter in the $routeProvider
. The problem is, I get $route.current is undefined
error. Why ?
myApp.config(['$routeProvider', function($routeProvider){
$routeProvider.when('/abc', {
...
action: 'X'
})
}]);
myApp.run(['$rootScope', '$route', '$location', 'authService',
function ($rootScope, $location, $route, authService) {
$rootScope.$on('$routeChangeSuccess', function (currentRoute, previousRoute) {
if ($route.current.action) {
$rootScope.action = $route.current.action;
}
});
)]
I think the function paramerters have an incorrect order, following is the correct order.
function ($rootScope, $route, $location, authService) {
Also, as stated by @Clive, you probably need to change the signature of the function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.