Ich versuche progressBar
von AngularUIBootstrap zu verwenden.
Ich habe eine objectFactory.js Datei:
(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)
{}
}());
Es ist wirklich seltsam ist, aber wenn ich neue Abhängigkeit hinzufügen $sanitize
:
objectiveFactory.$inject = ['$http', '$animate', '$sanitize'];// not working
Dann habe ich einen Fehler bekam:
angular.js:13920 Error: [$injector:unpr] http://errors.angularjs.org/1.5.8/ $injector/unpr?p0=sanitizeProvider%20%3C-%20sanitize%20%3C-%20objectiveController at Error (native) at http://localhost:15533/Scripts/angular.min.js:6:412 at http://localhost:15533/Scripts/angular.min.js:43:174 at Object.d [as get]
Aber '$http'
und '$animate',
Injektionen funktioniert perfekt.
Ich habe eine Menge Infos erforscht und geprüft doppelt folgende Hinweise in meiner Web-API-Anwendung:
I Versionen
angular'js
Datei undangular-sanitize.js
überprüft haben, und sie sind die gleichen1.5.8
.Meine Bundle-Dateien wie folgt aussehen:
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" ));
ich verschiedene Möglichkeiten der Injektion versucht haben:
objectiveController.$inject = ['$scope', '$http', 'objectiveFactory', '$animate', 'ngSanitize']; objectiveController.$inject = ['$scope', '$http', 'objectiveFactory', '$animate', '$sanitize']; objectiveController.$inject = ['$scope', '$http', 'objectiveFactory', '$animate', 'sanitize'];
jedoch der Fehler gleich ist:
angular.js:13920 Error: [$injector:unpr] Unknown provider:
Hat jemand kn Was habe ich falsch gemacht? ('$http'
Injektion funktioniert perfekt)
hast du ngSanitize in dein Hauptmodul injiziert? –
@PoyrazYilmaz ooops, was ist das Hauptmodul? Ich habe nur zwei JavaScript-Dateien: 'objectoveFactory' und' objectiveController'. – StepUp
angular.module ('app', []) hier ist dein Hauptmodul und du hast hier nichts injiziert. Es ist normal, dass $ https funktioniert, weil es mit Core kommt, aber Sie müssen ngSanitize injizieren, um $ die Arbeit zu sanieren ... –