Reputation: 85
While trying to get data from the "resolve" object. I cannot get anything from what is found in the parent component.
function partnerCtrl($uibModal, get, role, loader, toastr, $translate) { ...
vm.search = () => {
loader.show();
get.searchUser(vm.userId, vm.type).then((res) => {
if (res.data.d.results.length) {
const modalInstance = $uibModal.open({
animation: true,
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
component: 'partnerList',
size: 'lg',
resolve: {
items() {
return res.data.d.results;
},
},
});
}
function partnerListCtrl($scope, uiGridConstants) {
const $ctrl = this;
$ctrl.items = this.resolve.items;
this.gridOptions = {...},
],
data: this.resolve.items,
};
...
}
Upvotes: 0
Views: 36
Reputation: 545
items
should be a named property in your resolve's members
...
resolve: {
items: () => {
return res.data.d.results;
},
},
...
Note that it is an arrow function to ensure res
is still in scope.
Lastly, you should be able to have this resolved value injected into your controller's constructor. When declaring the controller, the injection token string is the same as the member name in your resolve object, in this case "item"
function partnerListCtrl($scope, uiGridConstants, items) {
const $ctrl = this;
$ctrl.items = items;
this.gridOptions = {...},
],
data: this.resolve.items,
};
...
}
app.controller("partnerList", ["$scope", "uiGridConstants", "items", partnerListCtrl]);
Upvotes: 0