2016-05-21 12 views
1

Im haben 2 <router-outlet> und alles ist in Ordnung, das ist mein RouteConfig in der Profilkomponente:kippe Gebrauch [Router] innerhalb der Komponente

mein Problem ist, wenn ich will [Router] innerhalb der credit Komponente throw ein Fehler: "Kredit" hat keine Route-Konfiguration. in [null]

und das ist meine credit Komponente:

import {ROUTER_DIRECTIVES,RouteConfig} from 'angular2/router'; 
@Component({ 
    selector : "credit", 
    templateUrl : "client/tmpl/profile/credit.html", 
    directives: [ROUTER_DIRECTIVES] 

}) 

Vorlage:

<ul> 
           <li><a [routerLink]="['Profile' , 'Home']" href="#">home</a> </li> 
</ul> 

warum ich RouteConfig innerhalb credit Komponente verwenden soll und wie nutzen?

Antwort

2

diese

<a [routerLink]="['/Profile' , 'Home']" href="#">home</a> 

Wie ich versuchen zu sehen, haben Sie Profile Route in der Hauptkomponente definiert und dann hat Profile Kind-Komponenten, dh: Home.

So tritt Ausnahme, weil:

  • Profile in dem Router bedeutet in dieser Komponente routeConfig für die Route suchen.

  • aber Sie müssen /Profile in Router tun, es zu sagen, für Profile Route in der Wurzel (Hauptbestandteil) 's routeConfig

+0

Vielen Dank –

+0

das ist Arbeit für me.thanks ein schauen Menge –

Verwandte Themen