controller.js.controller('NearCtrl', function($scope, $http, $cordovaSQLite, EventService) {
EventService.getDataFromDB().then(function(result) {
if (result.length > 0) {
EventService.populateData(result).then(function(items) {
$scope.items = items;
})
} else {
EventService.getDataFromApi().then(function() {
EventService.getDataFromDB().then(function(result) {
EventService.populateData(result).then(function(items) {
$scope.items = items;
})
})
})
}
});
})
services.js.factory('EventService', function($http, $cordovaSQLite) {
return {
//some code here..
populateData: function(data) {
var items = [];
for (i = 0; i < data.length; i++) {
items.push(data[i]);
}
return items;
}
}
})
Получаю TypeError: EventService.populateData(...).then is not a function
Что не так? Спасибо.