Currently, I am attempting to execute a resolve function upon a state change in order to retrieve data that I need to inject into a controller that utilizes "multiple" views. The rationale behind having nested views is due to the presence of a template/app.html
which incorporates a <ion-side-menu>
. My objective is to resolve data within the <side-menu-content>
.
CODE
Module Configuration:
$stateProvider.state('app', {
url: '/app',
abstract: true,
templateUrl: 'template/app.html'
})
.state('app.list', {
url: '/list',
views: {
'maincontainer@app': {
controller: 'listctrl',
templateUrl: 'template/list.html',
resolve: {
item: function(dataservice) {
return dataservice.getItems();
}
}
}
},
resolve: {
auth: auth
}
});
Controller:
angular.module('controller', []).controller('listctrl',
['$scope', function($scope, items){
console.log(items); // prints undefined
}]);
ISSUE
The main problem lies in the fact that the resolved items are not being injected into the controller, even though the item
function is being resolved.
I have been contemplating the idea of potentially storing the data in local storage upon resolution and then retrieving the items once again from the controller. I would prefer to avoid taking that approach if possible.