TypeError: Cannot read property 'get' of undefined on AngularJS

Viewed 41236

I am new on AngularJS and I got that error. Here is my code:

app.factory('NotificationService', function($http){
    var factory = {};
    factory.getNotificationList = function($http){
        var url = "http://some/url";
        return $http.get(url);
    }
    return factory;
});

app.controller('NotificationListController', function($scope,$http, NotificationService) {
    var notificationList = NotificationService.getNotificationList();
    notificationList.then(function(response){
        console.log(response);
        $scope.notificationData = response.data;
        return response;
    });
});

I am so confuse where my mistake is. The error message is:

TypeError: Cannot read property 'get' of undefined at Object.factory.getNotificationList (http://localhost:63342/EmailNotification/js/email-angular.js:15:21)

2 Answers
Related