I just started learning angularjs and I'm having trouble with calling a function in a factory. The error message I am receiving is as follows:
Error: [$injector:undef] Provider 'todoStorage' must return a value from $get factory method.
Here is my factory code:
todomvc.factory('todoStorage', function ($q,$http) {
var STORAGE_ID = 'todos-angularjs-perf';
function get(){
var promise = $q.defer();
$http.get('http://localhost/test.php').success(function(data){
promise.resolve(data);
});
return promise.promise;
}
});
This is how I am trying to call the function:
var todos = $scope.todos = todoStorage.get();
I would like to understand what exactly is causing this error to occur? Can someone please explain?