错误[$ injector:unpr]注入清理依赖项时
我试图使用progressBar
从AngularUIBootstrap。
我有一个objectFactory.js文件:
(function () {
var objectiveFactory = function ($http, animate) {
debugger;
return {
getObjectives: function () {
return $http.get('/api/Objective/');
}
};
};
debugger;
try {
//objectiveFactory.$inject = ['$http', '$animate', '$sanitize'];// error
objectiveFactory.$inject = ['$http', '$animate'];// no error
angular.module('app', []).factory('objectiveFactory', objectiveFactory);
}
catch (e)
{}
}());
这真的很奇怪,但是如果我添加新的依赖项$sanitize
:
objectiveFactory.$inject = ['$http', '$animate', '$sanitize'];// not working
然后我有一个错误:
angular.js:13920错误:[$ injector:unpr] http://errors.angularjs.org/1.5.8/$injector/unpr?p0=sanitizeProvider%20%3C-%20sanitize%20%3C-%20objectiveController at在http:// localhost:15533 / Scripts / angular.min.js:43:174位于http:// localhost:15533 / Scripts / angular.min.js:6:412时出现错误(本机)得到]
但是'$http'
和'$animate',
注射完全起作用。
我已经探索了很多信息,并在我的Web API应用程序中检查了以下建议:
我检查过版本angular'js
文件和angular-sanitize.js
,它们是1.5.8
。
我的包文件如下所示:
bundles.Add(new ScriptBundle("~/bundles/angularjs").Include(
"~/Scripts/jquery-1.10.2.min.js",
"~/Scripts/bootstrap.min.js",
"~/Scripts/angular.min.js",
"~/Scripts/angular-animate.min.js",
"~/Scripts/angular-sanitize.min.js",
"~/Scripts/ui-bootstrap-tpls-2.1.3.js",
"~/Scripts/objectiveFactory.js",
"~/Scripts/objective.js"
));
我尝试了各种注射方法:
objectiveController.$inject = ['$scope', '$http', 'objectiveFactory', '$animate', 'ngSanitize'];
objectiveController.$inject = ['$scope', '$http', 'objectiveFactory', '$animate', '$sanitize'];
objectiveController.$inject = ['$scope', '$http', 'objectiveFactory', '$animate', 'sanitize'];
但是,错误是一样的:
angular.js:13920错误:[$ injector:unpr]未知提供者:
有人知道我做错了什么吗? ( '$http'
注入完美的作品)
将ngSanitize注入您的主模块以使用$ sanitize ...
你需要为$ animate做同样的事情,注入ngAnimate
链接地址: http://www.djcxy.com/p/77681.html上一篇: Error [$injector:unpr] when injecting sanitize dependency