Yakov Fain
Yakov Fain

Reputation: 12376

Is Angular 2 Auxiliary router broken?

I'm trying to create an app with an auxiliary route for a chat window. The app fails right on the loading. It seems like a bug and I reported it on Angular GitHub, but I wonder if anyone knows a workaround? Here's the plunk of this simple app: http://plnkr.co/edit/JsZbuR

@Component({
  selector: 'basic-routing',
  template: `
    <a [router-link]="['/Home']">Home</a>
    <a [router-link]="['/ProductDetail']">Product Details</a>
    <router-outlet></router-outlet>
    <router-outlet name="chat"></router-outlet>
    <a [router-link]="['/', ['Chat']]">Chat</a>
  `,
  directives: [ ROUTER_DIRECTIVES ]
})
@RouteConfig([
  {path: '/',        component: HomeComponent,          as: 'Home'},
  {path: '/product', component: ProductDetailComponent, as: 'ProductDetail'         },
  {aux:  '/chat',    component: ChatComponent,          as: 'Chat'}
])
class RootComponent { /* ... */ }

It's not clear how the router knows which named route outlet to use.

Upvotes: 2

Views: 1570

Answers (1)

przemcio
przemcio

Reputation: 397

You have to wait until the issue https://github.com/angular/angular/issues/4694 will be solved.

Current implementation allows only

this.router.navigateByUrl('/(chat)');

See the link http://plnkr.co/edit/lquMdagaVfIoAT83w1pl?p=preview

Upvotes: 4

Related Questions