TypeError: Cannot read property ‘get’ of undefined on AngularJS

You are getting this error because $http is undefined in your factory.

You can fix it by passing it to the factory like so:

app.factory('NotificationService', ['$http', function ($http) {
    var factory = {};
    factory.getNotificationList = function() { // Remove the `$http` parameter from here.
        var url = "http://some/url";
        return $http.get(url);
    }
    return factory;
}]);

Leave a Comment