apothekenService.getApotheke returns a promise. response.data within the promise is a json object which is delivered correctly, I can see that in the first console.log.
How can I get this json object to my variable in the resolve? When I do the same in a controller I just use $scope and bind the variable within the response but in this case I don't have a scope.
angular.module("test", ["ngAnimate", "ngCookies", "ngTouch", "ngSanitize", "ngResource", "ui.router", "ui.bootstrap", "ui.bootstrap.showErrors", "myApothekenService"]).config(function($stateProvider, $urlRouterProvider, $uiViewScrollProvider, showErrorsConfigProvider) {
$uiViewScrollProvider.useAnchorScroll;
return $stateProvider.state("root", {
abstract: true,
controller: "RootCtrl",
resolve: {
Apotheke: function(apothekenService) {
this.apo = {};
apothekenService.getApotheke().then(function(response) {
console.log(response.data);
return this.apo = response.data;
});
console.log(this.apo);
return this.apo;
}
}
});
}).controller("RootCtrl", function($scope, $location, $anchorScroll, Apotheke) {
$scope.apotheke = Apotheke;
console.log($scope.apotheke);
});