mongodb - Unknown provider error when injecting factory -


i using yeoman angular full stack generator. trying out todo items tutorial mongodb. worked fine i.e. able read db using $http.get. decided go further , create factory can perform curd.

after creating factory tried inject getting error follows:

error: [$injector:unpr] unknown provider: facttodoprovider <- facttodo http://errors.angularjs.org/1.2.6/$injector/unpr?p0=facttodoprovider%20%3c-nanacttodo @ http://localhost:9000/bower_components/angular/angular.js:78:12 @ http://localhost:9000/bower_components/angular/angular.js:3538:19 @ object.getservice [as get] (http://localhost:9000/bower_components/angular/angular.js:3665:39) @ http://localhost:9000/bower_components/angular/angular.js:3543:45 @ getservice (http://localhost:9000/bower_components/angular/angular.js:3665:39) @ invoke (http://localhost:9000/bower_components/angular/angular.js:3687:13) @ object.instantiate (http://localhost:9000/bower_components/angular/angular.js:3708:23) @ http://localhost:9000/bower_components/angular/angular.js:6758:28 @ link (http://localhost:9000/bower_components/angular-route/angular-route.js:897:26) @ nodelinkfn (http://localhost:9000/bower_components/angular/angular.js:6212:13)  

main.js controller looks

'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();     });  

where facttodo factory follows (todo.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 all', priority: '1500'}             ];             }     } }); 

i tried changing code in main.js described in angularjs error ref follows

angular.module('angularfsapp') .controller('mainctrl', ['$scope', '$http', 'facttodo', function ($scope, $http, facttodo) { 

as tried dan wahlin got same issue.

make sure file 'facttodo' included app.

for convenient development , avoid issues in future try grunt task runner concatenate code , include 1 file.

this tutorial seems sufficient starting grunt , file concatenation.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -