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)
$http
is declared twice within thefactory
. For the 2nd declaration, the named parameter forgetNotificationList()
, you aren't providing an argument to give it a value. – Jonathan Lonowski Mar 17 at 3:59