简体   繁体   中英

Unknown provider Error when trying to inject dependency on Angular controller

I'm trying to inject "modal" directive in my userMenuController the following way:

angular.module('mgApp.controllers').controller('userMenuController', ['$scope', 'modals', function($scope, modals) { ... }])

Here's modals.js:

angular.module('mgApp.directives').directive('modals', function(){ ... })

And on app.js, app is defined like this:

var app = angular.module('mgApp',['templates', 'angularUtils.directives.dirPagination', 'mgApp.filters', 'mgApp.directives', 'mgApp.services', 'mgApp.controllers']);

But I keep getting this error:

Error: [$injector:unpr] Unknown provider: modalsProvider <- modals <- userMenuController

What am I missing?

a quick thought: make sure you have included all .js files as

<script src="*.js"></script> 

in index.html file

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM