【发布时间】:2015-11-04 13:43:24
【问题描述】:
我正在尝试通过以下方式在我的 userMenuController 中注入“modal”指令:
angular.module('mgApp.controllers').controller('userMenuController', ['$scope', 'modals', function($scope, modals) { ... }])
这里是 modals.js:
angular.module('mgApp.directives').directive('modals', function(){ ... })
在 app.js 上,app 是这样定义的:
var app = angular.module('mgApp',['templates', 'angularUtils.directives.dirPagination', 'mgApp.filters', 'mgApp.directives', 'mgApp.services', 'mgApp.controllers']);
但我不断收到此错误:
Error: [$injector:unpr] Unknown provider: modalsProvider <- modals <- userMenuController
我错过了什么?
【问题讨论】:
-
为什么你不在同一个模块 mgApp 中的所有内容?我的意思是,你的指令和控制器?
标签: javascript angularjs angularjs-directive angular-controller