I am having problems executing a breeze request with angular permission before rendering the view. I am trying to get some data from the server before the view is rendered using a breeze. I use
$routeProvider.when('/countries', { templateUrl: 'App/partials/countries.html', controller: Ctrl, resolve: Ctrl.resolve }).
controller and service fragments:
function Ctrl($scope, Q, datacontext, countries) {
}
function getCountries(forceRefresh) {
var query = entityQuery.
from("countries").
orderBy("name");
return manager.executeQuery(query).
then(getSucceeded);
}
function getSucceeded(data) {
return data.results;
}
this makes my view never display:
Ctrl.resolve = {
countries: function (datacontext) {
return datacontext.getCountries();
}
}
whereas if I create a timer that takes longer, it works. I tried wrapping it with $ q, but I can't get it to work.
this will display the view due to timeout:
Ctrl.resolve = {
countries: function (datacontext) {
return datacontext.getCountries();
},
delay: function ($q, $timeout) {
var delay = $q.defer();
$timeout(delay.resolve, 6000);
return delay.promise;
}
}
If anyone can help me, that would be great. I'm not sure if I am doing something wrong or if there are restrictions with Q promises or a breeze in resolution.