I am trying to send data from factory to a controller but I get the following error:
$(http).get(...).success is not a function
Factory code:
app.factory('sportsFactory', ['$http', function($http) {
return $http.get('data/sports.json')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}]);
Controller code:
app.controller('NavbarController',['$scope', 'sportsFactory',
function($scope, sportsFactory){
sportsFactory.success(function(data){
$scope.sports = data;
});
}]);
If I pass a data without using $http it works!