2016-11-28 71 views
0

我在我的主模块中注入了AngularJs#1.3.8和ngRoute。所以,给当前的路线:在AngularJs的routeProvider中访问url 1

.when('/users', { 
        templateUrl : 'template.html', 
        controller: 'Users', 
        controllerAs : 'Users', 
        resolve: { 
         function (userService) { 
          return userService.initModuleRoles('/users', ['R-USERS']); 
         } 
        } 

在服务方法initModuleRoles第一个参数:'/用户可以使用非硬编码的变量替换? (类似$ route.url)

回答

1

可以传递到PARAMS你的决心:

.when('/users', { 
 
     templateUrl: 'template.html', 
 
     controller: 'Users', 
 
     controllerAs: 'Users', 
 
     resolve: { 
 
     lazy: ['userService','$location', function(userService,$location) { 
 
      return userService.initModuleRoles($location.url(), ['R-USERS']); 
 
     }] 
 
     } 
 
    });

+0

那么,谁是$ myVar的? – que1326

+0

@ que1326,任何你想要的,在我们的例子中是'$ state'。为什么要投票? – Erevald

+0

我没有投下你的答案。 $ state属于ui.router,我正在使用ngRoute ... – que1326