Reputation: 1907
I'm following the instructions on the ui-router wiki which relates to working with resolves. If I follow the instructions on the wiki I get the value shared in to the controller without an issue, if I include the controller by reference the value is undefined. What am i missing?
.state('intro', {
url: '/',
resolve:{
resA: function(){
return {'value': 'A'};
}
},
views: {
'content': {
templateUrl: 'views/home.html',
controller: function($scope, resA){
$scope.resA = resA.value;
}
},
'navigation': {
templateUrl: 'views/navigation.html'
}
} })
.controller('introController', ['$scope', function($scope,resA) {
$scope.resA = resA.value; //undefined
Upvotes: 2
Views: 2121
Reputation: 123901
There is a working example
We have to declare this controller, e.g. as a part of state def:
'navigation': {
template: '<div>navi - resA: {{resA}}</div>',
controller: 'introController',
},
then we have to properly pass arguments (the 'resA' must be passed as well)
.controller('introController', ['$scope', 'resA'
, function($scope,resA) {
$scope.resA = resA.value; //undefined
}])
;
Working plunker
Upvotes: 1
Reputation: 30118
This is because you did not include resA
in your array notation, it should be like this:
.controller('introController', ['$scope', 'resA', function($scope, resA) {
$scope.resA = resA.value;
}]);
Upvotes: 5