I'm using AngularJS's UI-Router to manage routes for my web application.
I have two states: parent_state
and child_state
arranged as shown below.
$stateProvider
.state('parent_state', {
abstract: true,
views: {
'@' : {
templateUrl: 'http://example.com/parent.html',
controller: 'ParentCtrl'
}
}
})
.state('child_state', {
parent: 'parent_state',
url: '/child',
params: {
myArg: {value: null}
},
views: {
'mainarea@parent_state': {
templateUrl: 'http://example.com/child.html',
controller: 'ChildCtrl'
}
}
})
From within ChildCtrl
, I can access myArg
like this:
app.controller("ChildCtrl", function($stateParams) {
console.log('myArg = ', $stateParams.myArg);
});
Is it possible for me to access myArg
and have it displayed in the html page parent.html
? If so, how can it be done? I see that the ParentCtrl
controller for the abstract state is never even called.
This question addresses a related topic. But it doesn't show me how to display a parameter to the child state in a template of the parent state.