I have a service to share an object in my app... I want to post that object to the mongo db but when I call the function that should return the object it gives me the function's text.
The service is here:
angular.module('comhubApp')
  .service('markerService', function () {
  this.markers = [];
    this.newMarker = {  title: '',
        description: '',
        lat: '',
        lon: '',
        user: '',
        created_at: '' };
// This is supposed to return the marker object
    this.newMarker = function  () {
        return this.newMarker;
    };
    this.setTitle = function (title) {
        this.newMarker.title = title;
        console.log('title service set: ' + title);
    };
    this.setDescription = function (description) {
        this.newMarker.description = description;
        console.log('Description service set: ' + description);
    };
    this.setLat = function (lat) {
        this.newMarker.lat = lat;
        console.log('lat service set: ' + lat);
    };
    this.setLon = function (lon) {
        this.newMarker.lon = lon;
        console.log('lon service set: ' + lon);
    };
    this.reset = function () {
        this.newMarker =  { title: '',
            description: '',
            lat: '',
            lon: '',
            user: '',
            created_at: ''};
            }
    this.setMarkers = function (markers) {
        this.markers = markers;
    }
    this.markers = function () {
        return this.markers;
    }
    this.addMarker = function (marker) {
        //todo append marker
    }
});
newMarker returns:
this.newMarker = function  () {
        return this.newMarker;
    };
The Controller using the service is here
$scope.addMarker = function() {
if($scope.newMarker.title === '') {
    console.log('newMarker title is empty');
  return;
}
markerService.setTitle($scope.newMarker.title);
markerService.setDescription($scope.newMarker.description);
console.log(markerService.newMarker());
// $http.post('/api/markers', { name: $scope.newMarker });
// $scope.newMarker = '';
};
$scope new marker is form data.. i tried to put that right into my service with no success. Instead I out the form data into the controller then push it to the service. If there is a better way to do that please let me know.
If this service is bad in any other way let me know I am new to all this and so I followed another answer I saw on here.
 
    