简体   繁体   English

尝试在Angular控制器上注入依赖项时出现未知提供程序错误

[英]Unknown provider Error when trying to inject dependency on Angular controller

I'm trying to inject "modal" directive in my userMenuController the following way: 我正在尝试通过以下方式在userMenuController中插入“模态”指令:

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

Here's modals.js: 这是modals.js:

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

And on app.js, app is defined like this: 在app.js上,app的定义如下:

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 快速思考:确保已将所有.js文件包含为

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

in index.html file 在index.html文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试依赖向AngularJs中的控制器注入服务时出现未知的提供程序错误 - Unknown provider error when trying to dependency inject a service to a controller in AngularJs 尝试从另一个模块插入服务时出现未知的提供程序错误 - Unknown provider error when trying to inject a service from another module 未知提供程序错误,依赖注入,模态控制器 - Unknown Provider Error, Dependency Injection, Modal Controller 错误未知提供程序:$ scopeProvider &lt;-使用$ injector将$ scope注入控制器时的$ scope - Error Unknown provider: $scopeProvider <- $scope when using $injector to inject $scope into controller 使用ngClipboard的Angular控制器-错误:未知的提供程序 - Angular Controller Using ngClipboard - Error: Unknown provider 控制器的未知提供程序错误 - Unknown provider error for controller 在控制器中使用服务时使用Angular ui-router时出现“Unknown Provider”错误 - “Unknown Provider” error when using Angular ui-router when using service in controller 未知的提供程序错误角度 - Unknown Provider error Angular 角度未知提供程序错误 - Angular unknown provider error Angular在将工厂注入控制器时抛出Unknown provider - Angular is throwing Unknown provider when injecting factory into controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM