Monday, October 16, 2017

Angular JS Service not hitting server

I have created this service .
and using enrollments.getProperty(); this statement to call this service but its not working i’m new to angular-JS please let me know where i’m making the mistake.

var helloAjaxApp = angular.module("myApp", []);
helloAjaxApp.service('enrollments',  [ '$scope', '$http', function ($scope, $http) {

    $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8";
    var enrollments = null;
    enrollment();
    $scope.enrollment=function () {
         $http({
        url : 'enrollments',
        method : "GET"
    }).then(function(response) {

        enrollments = response.data;
        alert("enrollments");
    });
    };
    return {
        getProperty: function () {
            return enrollments;
        },
        setProperty: function(value) {
            enrollments = value;
        }
    };
}]);

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/16/angular-js-service-not-hitting-server/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment