我有我的应用程序:
'use strict';
angular.module('ProjectTracker', [
'App.controllers',
'App.services'
])
我的服务:
angular.module("App.services", [])
.factory('ProjectManager', function () {
return {
getAll: function () {
return [{ID:'123123', Name:'2313'}];
}
}
});
我的控制器:
var appCtrl = angular.module('App.controllers', ['App.services']);
var ProjectsListController = ['$scope', 'ProjectManager', function ($scope, ProjectManager) {
$scope.projectList = ProjectManager.getAll();
}];
appCtrl.controller('ProjectsListController', ProjectsListController);
但是当我开始时,它会抛出这个:
Error: [$injector:unpr] http://errors.angularjs.org/1.2.16/$injector/unpr?p0=ProjectManagerProvider%20%3C-%20ProjectManager t/<@http://localhost:14967/Areas/ProjectTrack/Scripts/angular .min.js:6 ac/m.$injector<@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:35 c@http:// localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:34 ac/p.$injector<@http://localhost:14967/Areas/ ProjectTrack/Scripts/angular.min.js:36 c@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:34 d@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:34 ac/g/<.instantiate@http://localhost:14967/ Areas/ProjectTrack/Scripts/angular.min.js:34 Od/this.$get</<@http://localhost:14967/Areas/ProjectTrack/Scripts/ angular.min.js:66 cc/this.$get</ia/J/<@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:53 q@http:// localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:7 J@http://localhost:14967/Areas/ProjectTrack/Scripts/ angular.min.js:52 f@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:46 f@http://localhost:14967/ Areas/ProjectTrack/Scripts/angular.min.js:46 cc/this.$get</x/<@http://localhost:14967/Areas/ProjectTrack/Scripts/ angular.min.js:46 $b/c/</<@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:18 Yd/this.$get</h. prototype.$eval@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:108 Yd/this.$get</h. prototype.$apply@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:109 $b/c/<@http://localhost:14967/ Areas/ProjectTrack/Scripts/angular.min.js:18 d@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:34 $b/c@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:18 $b@http://localhost:14967/Areas/ ProjectTrack/Scripts/angular.min.js:18 Wc@http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:17 @http://localhost:14967/Areas/ProjectTrack/Scripts/angular.min.js:209 jQuery.Callbacks/fire@http://localhost:14967/ Scripts/jquery-2.0.3.js:2913 jQuery.Callbacks/self.fireWith@http://localhost:14967/Scripts/jquery-2.0.3.js:3025 . ready@http://localhost:14967/Scripts/jquery-2.0.3.js:398 completed@http://localhost:14967/Scripts/jquery-2.0.3.js:93
我尝试了很多方法来注入我的服务,但没有任何效果。这个 angular-app 是大型 C# .NetMVC 项目的一部分,但编译模式是调试 -
<compilation debug="true" targetFramework="4.5" />
所以,它不应该重命名我的变量(应该关闭缩小)。我如何使用我的服务?