AngularJS 未知提供程序
AngularJS Unknow provider
我试图在我的 Angular 应用程序中设置一个新的控制器,但我遇到了这个错误:
[$injector:UNPR] http://errors.angularjs.org/1.4.2/$injector/unpr?p0=successRedirectProvider%20%3C-%20successRedirect%20%3C-%20ingreCtrl。
我尝试了很多东西几个小时,但仍然有这个问题。这是我的文件:
应用.js:
var app = angular.module('app', ['formSubmit']);
app.factory('successRedirect', function(){
return function(data) {
if(data.status === "success") {
alert(data.message);
if (typeof(data.redirect) !== "undefined"){
document.location.href = data.redirect;
}
}else{
}
};
});
app.factory('errors', function(){
return function(data) {
alert(data.message)
for(var i = 0; i<data.errors.length;i++){
$('#new-page-form-container').append('<p>'+data.errors[i]+'</p>');
}
};
});
表单应用.js:
var formSubmit = angular.module('formSubmit', ['ckeditor', 'ngFileUpload']);
成分控制.js:
formSubmit.controller('ingreCtrl', ['$scope', '$filter', '$http', 'successRedirect', 'errors', function ($scope, $filter, $http, successRedirect, errors) {
}]);
您正在尝试在formSubmit
模块中使用app
模块的successRedirect
服务。这意味着您需要将依赖项注入app
formSubmit
:
var formSubmit = angular.module('formSubmit', ['app', 'creditor', 'ngFileUpload']);
^^^^^
反之则不然。
我终于找到了它不起作用的原因,上周我在另一个文件中为我网站的登录系统做了另一个模块,我不记得我已经给这个模块起了名字"app",所以我在文件应用程序中更改了我的模块名称.js它就可以工作了。但是要回答一些评论,我的依赖注入很好,作为我的包含,不需要更改顺序。问题是模块名称。无论如何,感谢您的时间,主题关闭^^
相关文章:
- 为什么我得到错误:$injector:unp未知提供程序
- 在出厂时注入服务错误: [$injector:unpr] 未知提供程序: $scopeProvider <- $scop
- AngularJS错误:$injector:unp未知提供程序-$modalInstanceProvider
- AngularJS:未知的提供程序错误
- Angular小部件中的Angular Grid返回错误:[$injector:unp]未知提供程序:
- 有角度的“;未知提供者”;在约曼应用程序中使用Grunt Build缩小后出错
- 获取解析值的未知提供程序错误
- $provide.decorator为指令提供未知的提供程序
- jQuery - 追加/替换事件侦听器(当事件处理程序未知时)
- angular.js:13294错误:[$injector:unp]未知提供程序:cityResourceProvide
- 角度未知提供程序,无法POST/注册
- 未知提供程序:在angular.bootstrap之前使用$injector获取$location服务时使用$rootE
- Watir Web驱动程序引发未知Javascript错误
- ionic.bundle.js:25642错误:[$injector:unp]未知提供程序:$cordovaGeoloc
- 密钥斗篷未知提供程序错误
- Angular 未知提供程序,出厂时包装在匿名函数中
- ui选择未知提供程序
- 错误: [$injector:unpr] 未知提供程序: setPageProvider <- setPage
- 错误:[$injector:unp]在控制器中注入routeprovider服务时,jasmine测试中的提供程序未知
- uib模态提供程序未知单元测试