저는 yeoman 각 풀 스택 생성기를 사용하고 있습니다. MongoDB로 ToDo 항목 튜토리얼을 시험해 보았습니다. 모든 것이 잘 작동했습니다. 즉 $ http.get을 사용하여 DB에서 읽을 수있었습니다. 그러나 나는 더 나아가서 CURD를 수행 할 수있는 공장을 만들기로 결정했습니다.공장 투입시 알 수없는 공급자 오류입니다.
Error: [$injector:unpr] Unknown provider: factToDoProvider <- factToDo
http://errors.angularjs.org/1.2.6/$injector/unpr?p0=factToDoProvider%20%3C-NaNactToDo
at http://localhost:9000/bower_components/angular/angular.js:78:12
at http://localhost:9000/bower_components/angular/angular.js:3538:19
at Object.getService [as get] (http://localhost:9000/bower_components/angular/angular.js:3665:39)
at http://localhost:9000/bower_components/angular/angular.js:3543:45
at getService (http://localhost:9000/bower_components/angular/angular.js:3665:39)
at invoke (http://localhost:9000/bower_components/angular/angular.js:3687:13)
at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:3708:23)
at http://localhost:9000/bower_components/angular/angular.js:6758:28
at link (http://localhost:9000/bower_components/angular-route/angular-route.js:897:26)
at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:6212:13)
Main.js 컨트롤러가 factToDo은 다음과 같이 내 공장입니다
'use strict';
angular.module('angularFsApp')
.controller('MainCtrl', function ($scope, $http, factToDo) {
$http.get('/api/awesomeThings').success(function(awesomeThings) {
$scope.awesomeThings = awesomeThings;
});
$http.get('/todo/todoItems').success(function(todoItems) {
$scope.todoItems = todoItems;
});
//$scope.newtodoItems = factToDo.getAllItems();
});
(잭처럼 보이는 다음과 같이
공장을 만든 후 나는 그것을하지만 점점 오류를 주입 시도 .js)
angular.module('angularFsApp')
.factory('factToDo', function() {
return {
getAllItems: function() {
return [
{description: 'Hello World 1', priority: '15'},
{description: 'Hello World 2', priority: '15'},
{description: 'Love for all', priority: '1500'}
];
}
}
});
에서 설명한대로 main.js에서 코드를 변경해 보았습니다.내가 Dan Wahlin을 시도하지만 난 같은 문제를 가지고뿐만 아니라
angular.module('angularFsApp')
.controller('MainCtrl', ['$scope', '$http', 'factToDo', function ($scope, $http, factToDo) {
을 다음과 같이.
'factToDo'가 정의되었으므로 js 파일을 포함합니까? –
@IgorMalyk 문제가되었음을 고맙습니다. – AAWaheed