I am new to angular. I have a service where I call a function by another function within the service. But in my controller is shows as undefined. See below
//my Service
myApp.service("LocationService", function() {
var srv = {}
srv.msg = {long:0, lat:0};
srv.onSuccess = function() {
this.msg.lat = 32;
},
srv.onError = function() {
this.msg.long = 99;
},
srv.getGpsFix = function() {
this.onSuccess();//fails in controller
}
return srv;
});
//my Controller
myApp.controller("MusicCtrl", ["$scope", "LocationService", function($scope, LocationService) {
//undefined
console.log(locationService.getGpsFix());
}]);
srv.onSuccess = function() { /* ... */ },, dosrv.onSuccess = function() { /* ... */ };.