Vote count:
0
I used to resolve promises like this, but suddenly it stopped working:
$routeProvider
.when('/view', {
templateUrl: 'views/view.html',
controller: 'MyContoller',
resolve: {
queryset: function (MyService) {
return MyService.fetch();
}
}
})
app.controller('MyController', ['$http', '$scope', 'queryset',
function ($http, $scope, queryset) {
$scope.queryset = queryset;
console.log(queryset);
}
]);
console.log(queryset) gives [$promise: d, $resolved: false]. If I open the object, I can see that the API data is loaded successfully and the only thing wrong with the promise is $resolved:false.
Strangely enough, if I add new variable to resolve function, the promise is resolved on page refresh, but never when I change the routes.
asked 2 mins ago
Promise is not resolved - AngularJS
Aucun commentaire:
Enregistrer un commentaire