If using Ui-Router with AngularJS and TypeScript, can I access the properties defined in a parent state from the nested estate directly (without using params or data)?
I can use $state.$current.parent to access data in the data property, but I would like to access a property defined in the controller directly. I have called it xxx in the sample code provided.
Here is my example:
THE ROUTES:
$stateProvider
.state(STATE_NAMES.JOB_ADD.MAIN, {
url: '/jobs/:Id',
redirectTo: STATE_NAMES.JOBL_ADD.DETAILS,
views: {
'content': {
component: COMPONENT_NAMES.JOBS_ADD.MAIN
}
}
})
// nested states
.state(STATE_NAMES.JOB_ADD.DETAILS, {
url: '/details',
views: {
'section': {
component: COMPONENT_NAMES.JOBS_ADD.DETAILS
}
}
})
THE PARENT STATE CONTROLLER
public xxx: string; //I want to access this property from the controller
constructor(
private talentPoolAddService: ITalentPoolAddService,
private $state: router.StateService,
private $scope: ng.IScope,
) {
this.xxx = 'ascs';
}
bindings = {
application: '<',
applicationId: '<',
xxx: '<'
};
PARENT VIEW
<form>
<section ui-view="section"> <!-- nested views are rendered here-->
<button>....</button>
</form>
THE NESTED STATE CONTROLLER
public xxx: string;
bindings = {
application: '<',
applicationId: '<',
xxx: '<'
};
NESTED VIEW
<p> {{$ctrl.xxx}} </p>//nothing
Thanks.