I want to call a callback function but i can't get the data because my call is wrong.
I tried:
//function with callback
filterList: function(type, cb) {
if (type == 'all') {
var resource = infoboxApi.resource1().query();
} else if (type == 'group') {
var resource = infoboxApi.resource2().query();
}
resource.$promise.then(function(events) {
var eventContainer = [];
angular.forEach(events, function(event) {
eventContainer.push({
id: event.id,
title: event.title
})
});
cb(eventContainer);
});
return wrapSaveHandlers(resource);
}
//call i tried
var newSources = [];
filterList('all', function(result) {
newSources = result;
});
I want newSources to contain the data but it's empty if i call it like this.
Anyone know how to call it the right way?