I create it has a service, and then pass it to my controller, The problem is that i have it to read a static file only (1.json), and now that i have populated this folder with more than one json, i would like to know, how can I bring them all in, and make this call dynamically.
Service:
todoApp.factory('eventData', function($http, $q){
return {
getEvent: function(){
var deferred = $q.defer();
$http({method: 'GET', url: '/data/phonebook/1'}).
success(function (data, status, headers, config){
deferred.resolve(data);
}).
error(function (data, status, headers, config){
deferred.reject(status);
});
return deferred.promise;
}
};
});
Controller:
todoApp.controller('FeederController',
function FeederController($scope, eventData) {
eventData.getEvent().then(
function(event){$scope.event = event;},
function(statusCode) {console.log(statusCode)});
}
);
Best Wishes