The fact is that overriding the template in the child state of 'root.home' looks like this:
.state('root.home', { ... ->> 'layout@': { templateUrl: 'system/views/layouts/full-width.html' }
In fact, any part of the parent "root" is completely removed. So now we have to use this for sister visions:
'header@root.home': { // see the 'root.home' after @ templateUrl: 'system/views/partials/header2.html' }, '@root.home': { // see the 'root.home' after @ templateUrl: 'system/views/index.html' },
See that we used root.home after @ . That is: We directly say:
- find
ui-view="header" and unnamed ui-view="" inside this , current state of 'root.home' .
In the parent state "home" there is no goal, because we completely missed it.
The sample in the documentation in this case is really self-descriptive:
(cited by himself describing the fragment)
$stateProvider .state('contacts', { // This will get automatically plugged into the unnamed ui-view // of the parent state template. Since this is a top level state, // its parent state template is index.html. templateUrl: 'contacts.html' }) .state('contacts.detail', { views: { //////////////////////////////////// // Relative Targeting // // Targets parent state ui-view // //////////////////////////////////// // Relatively targets the 'detail' view in this state parent state, 'contacts'. // <div ui-view='detail'/> within contacts.html "detail" : { }, // Relatively targets the unnamed view in this state parent state, 'contacts'. // <div ui-view/> within contacts.html "" : { }, /////////////////////////////////////////////////////// // Absolute Targeting using '@' // // Targets any view within this state or an ancestor // /////////////////////////////////////////////////////// // Absolutely targets the 'info' view in this state, 'contacts.detail'. // <div ui-view='info'/> within contacts.detail.html "info@contacts.detail" : { } // Absolutely targets the 'detail' view in the 'contacts' state. // <div ui-view='detail'/> within contacts.html "detail@contacts" : { } // Absolutely targets the unnamed view in parent 'contacts' state. // <div ui-view/> within contacts.html "@contacts" : { } // absolutely targets the 'status' view in root unnamed state. // <div ui-view='status'/> within index.html "status@" : { } // absolutely targets the unnamed view in root unnamed state. // <div ui-view/> within index.html "@" : { } });
Also, pay attention to this important fact:
Keep in mind that region properties only inherit the state chain if views of your states are nested. Inheriting the properties of a region has nothing to do with the embedding of your states and everything related to the embedding of your views (templates).
It is possible that you have nested states whose templates populate u-views in different non-nested places on your site. In this case, you cannot expect access to the variables of the parent state view region in the child state views.
those. - we cannot inherit from the parent state "root" anyhting, because inheritance has only view types ...