Vah*_*afi 0 javascript angularjs angularjs-factory angularjs-injector
我正在使用angularJS,当我注入工厂时,我收到错误:
app.js:
angular.module('myapp', [])
Run Code Online (Sandbox Code Playgroud)
myfactory.js:
angular.module('myapp', [])
.factory('httpService', function($http, $timeout) {
});
Run Code Online (Sandbox Code Playgroud)
控制器:test.js:
angular.module('myapp', [])
.controller('test', function($scope, $timeout, $sce, $http, httpService) {
$scope.submit = function() {
}
});
Run Code Online (Sandbox Code Playgroud)
当我添加httpService我得到错误.一切似乎都是对的,我甚至在所有项目中都使用这个工厂.错误:
angular.min.js:92 Error: [$injector:unpr] http://errors.angularjs.org/1.2.25/$injector/unpr?p0=httpServiceProvider%20%3C-%20httpService
at Error (native)
at http://localhost:81/chah/assets/js/angularjs/angular.min.js:6:450
at http://localhost:81/chah/assets/js/angularjs/angular.min.js:36:202
at Object.c [as get] (http://localhost:81/chah/assets/js/angularjs/angular.min.js:34:305)
at http://localhost:81/chah/assets/js/angularjs/angular.min.js:36:270
at c (http://localhost:81/chah/assets/js/angularjs/angular.min.js:34:305)
at d (http://localhost:81/chah/assets/js/angularjs/angular.min.js:35:6)
at Object.instantiate (http://localhost:81/chah/assets/js/angularjs/angular.min.js:35:165)
at http://localhost:81/chah/assets/js/angularjs/angular.min.js:67:419
at http://localhost:81/chah/assets/js/angularjs/angular.min.js:54:25
Run Code Online (Sandbox Code Playgroud)
小智 6
检查错误中的链接(https://docs.angularjs.org/error/ $ injector/unpr?p0 = httpServiceProvider%20%3C-%20httpService):
您多次创建模块:
angular.module('myapp', [])
Run Code Online (Sandbox Code Playgroud)
你应该做一次.然后使用没有[]
angular.module('myapp').factory ...
angular.module('myapp').controller ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1944 次 |
| 最近记录: |