ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

Abstract state in Angular 2?

Open demisx opened this issue 10 years ago • 3 comments

Hi,

Is it possible to define abstract states in Angular 2 yet? Any example would be highly appreciated.

Thank you.

demisx avatar Jun 21 '16 15:06 demisx

Is it possible to define abstract states

yep. http://angular-ui.github.io/ui-router/1.0.0-alpha.5/interfaces/ng2.ng2statedeclaration.html#abstract

christopherthielen avatar Jun 22 '16 17:06 christopherthielen

Sorry, I've missed that page somehow. Very exciting to see my favorite router to retain the cool features in ng2.

demisx avatar Jun 22 '16 20:06 demisx

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 view, let's call it (main@)

@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.

Please advise if it's supported in NG2 module.

dissoupov avatar Jan 18 '17 16:01 dissoupov