javascript - Count number of files in Angular JS -
i need count files in folder total length
now have got 1 config factory length static
app.factory('srconfig', function() { return { length: 9, getfilefromid: function(id) { if (id < 10) { id = '0' + id; } return './data/data/sr-' + id + '.json'; } }; })
call factory config
app.factory('srprovider', function(srconfig, $q, $http) { return { getlist: function() { var deferred = $q.defer(); var sr = []; (var currentid = 1; currentid <= srconfig.length; currentid++) { sr.push($http.get(srconfig.getfilefromid(currentid))); }; $q.all(sr).then(function(response) { deferred.resolve(response); }, function(error) { console.log(error); deferred.reject(error); }); return deferred.promise; }, get: function(id) { return $http.get(srconfig.getfilefromid(id)); } } })
Comments
Post a Comment