Below is my Controller Code:
///////
//Diary Notes Controller
///////
diary.controller('NotesController', ['$scope','$http', 'notesService', function ($scope, $http, notesService){
//
//Get the Notes data back from the Server
//
$scope.updateFunc = function () {
var notes = notesService.getText();
console.log(notes);
};
$scope.updateFunc();
And my Services Code:
diary.factory('notesService', function ($http) {
return {
getText: function () {
$http.get('www/getNotes.php')
.then(
function (payload){
return payload.data;
});
}
}
});
Basically When I do console.log the controller returns undefined for the notes variable which seems awkward as when i was using the controller to get the payload it works but returning the payload from the services doesn't seems to work.