从路由器调用服务

时间:2013-12-22 17:32:08

标签: angularjs

我无法从路由器呼叫服务。以下是代码的结构。

angular.module('DTApp',[...]);
var dtAction = angular.module(...).controller(...);
dtAction.service('MenuService', menuService);  /* Service defined here */

dtAction.config(function($stateProvider, $urlRouterProvider) {
    MenuRouter($stateProvider, $urlRouterProvider);
});

var menuService = function() {
    this.getMenuItems = function() { return ... };
}

var MenuRouter = function($stateProvider, $urlRouterProvider, MenuService) {
   console.log(MenuService) /* Shows undefined */
}

0 个答案:

没有答案