So it seems I still don't understand promises correctly. I am using the angular resolve to prevent controller loading the view before the promise is resolve but its not working as expected. What I am doing wrong?
Here is my service
commonServicesModule.factory('helpdeskPriority', function($q, $timeout, getCommonList) {
var items;
return {
get: function(params) {
var defer = $q.defer();
$timeout(function() {
getCommonList.helpdesk.priority().success(function(result) {
console.log('waited for long tym ');
defer.resolve(result);
});
}, 0);
return defer.promise;
},
}
});
Call from controller
helpdeskPriority.get().then(function(data) {
console.log(data);
});
my priority function
priority: function() {
return $http({
url: urlc.getListing.priority,
data: {
"params": JSON.stringify({})
},
method: 'POST',
});
},