So I am sure I am not using best practices, but, I'm just trying to get this to work. I'm making a note taking app, and for whatever reason, the service I created, returns undefined and I can't figure out why.
Here's the service:
angular.module('notesService', []).factory('Notes', ['$http', function($http){
return {
get : function(){
var notes = $http.get('/api/notes');
return notes;
}
}
}]);
And here is the controller:
angular.module('mainController', [])
.controller('mainController', function($scope, Notes){
console.log(Notes.get());
});
The controller is not producing anything on the page just yet, i'm still testing.
Here is what the service returns to my controller:
e {
$$state : {
status : 1,
value : {
config : Object,
data: Array[10]
}
}
}
This isn't the entire thing, but it is all the stuff I need for my purposes.
Whenever I access $$state.value it returns undefined and I have no idea why.

.get()function returns. The odd thing, is that I can access$$statein the service by usingnotes.$$statebut anything below that i can't access.Notes.get().then (function (data){ //the data is what you are looking for});Thatget ()method is actually returning apromise, which when resolved you will get the data returned from the apiTypeError: Notes.get(...).then is not a functionnotesServiceintoangular.module('mainController', [notesService]). You dont need to add new module for each controller and services, you can have single module and add everything to it