NG2: Abstract named view regression
I'm migrating from UI-Router Angular 1.5 to Angular 2, and the root abstract state is not working as it's used to be.
I have a root named UIView, let's call it (main@), and AppMainPage component that defines nested views for Toolbar, Nav, Content, etc.
@Component({
selector: 'app',
styles: [],
template: `
<div ui-view="main" class="tw-view tw-column">
<div layout="column" layout-align="center center">
<div>loading ui-view...</div>
</div>
</div>
`
})
Registration:
UIRouterModule.forRoot({
states: [
{
name: 'app',
abstract: true,
views : {
'main@': AppMainPage,
'toolbar@app': AppToolbar,
'navigation@app': AppNavigation,
'quickPanel@app': AppQuickPanel
}
},
The AppMainPage is never initialized if I provide {views} option.
The same approach is working with UI-Router for Angular 1.5:
$stateProvider
.state('app', {
abstract: true,
views : {
'main@' : {
template: '<app-main-page class="tw-page-content row"></app-main-page>'
},
'toolbar@app' : {
template: '<app-toolbar></app-toolbar>',
},
'navigation@app': {
template: '<app-navigation></app-navigation>',
},
'quickPanel@app': {
template: '<app-quick-panel class="app-quick-panel"></app-quick-panel>',
}
}
})
;
Please advise if it's supported in NG2 module.
UPDATE: The docs seems to be misleading:
// Named views shorthand: // Inside a "views:" block, a Component class (NavBar) is shorthand for { component: NavBar }
Actually this does not work. 'main@': AppMainPage,
If I replace the statement with explicit 'component' option 'main@': { component: AppMainPage }, then abstract named views work great!
Oh, really sorry about that. I updated the docs before updating the code.
Track this issue: https://github.com/ui-router/ng2/issues/19