I am returning some route-specific data, and JSON is returning from the server perfectly, but I'm not sure how to access the object when I am in the controller. I tried several different things, for example, insert .then () inside the permission, but that did not work.
resolve: {
menus: function ($http) {
var httpSource = this.httpSource = location.protocol + '//' + location.hostname;
const url = `${this.httpSource}/api/package/menus`;
return $http.get(url);
}
}
I also tried this
resolve: {
menus: function ($http) {
var httpSource = this.httpSource = location.protocol + '//' + location.hostname;
const url = `${this.httpSource}/api/package/menus`;
var menuData;
$http.get(url).then(response => {
menuData = response.data.Data;
})
return menuData;
}
}
I just can't figure out how to load it into a controller property.
I tried to follow this, but the variable is not entered into the constructor - https://medium.com/opinionated-angularjs/advanced-routing-and-resolves-a2fcbf874a1c#.2xzq32cwo
I am trying to download it using
this.menuData = $state.current.resolve.menus;
And I get this object.
"$http", function $stateProvider.state.state.resolve.menus($http)]
I am sure that there is something fundamental, but I am new to Angular, I do not see this. Basically, my object is a complete function definition, not return.Data data.
.
static $inject = ['PackageService', '$stateParams', '$state', 'menus'];
constructor(packageService: Service.IPackageService, $stateParams, $state, DTOptionsBuilder, DTColumnDefBuilder, public logger: ILogger, public menus: any) {