javascript - jquery' title
組件內不能使用 (1)
嘗試這個
<a [routerLink]="['/Profile' , 'Home']" href="#">home</a>
正如我所看到的,您已經在主要組件中定義了Profile
路徑,然後Profile
具有子組件,即: Home
。
所以,發生異常是因為:
routerLink中的
Profile
表示查找此組件的routeConfig中的路由。但是您需要在routerLink中執行
/Profile
來告訴它在根(主要組件)的routeConfig中查找Profile
路徑
我有2 <router-outlet>
,一切正常,這個我的RouteConfig
裡的配置文件組件:
@Component({
selector : "profile",
templateUrl: '/client/tmpl/profile.html',
directives: [ ROUTER_DIRECTIVES],
})
@RouteConfig([
{name: 'Home', component: homeProfile ,path: '/' ,useAsDefault:true},
{name: 'Credit', component: credit ,path: '/credit' },
{name: 'BuyCredit', component: buyCredit ,path: '/buycredit' }
])
我的問題是當我想要使用credit
組件內的[routerLink]拋出一個錯誤:“信用”沒有路由配置。 在[null]
這是我的credit
組件:
import {ROUTER_DIRECTIVES,RouteConfig} from 'angular2/router';
@Component({
selector : "credit",
templateUrl : "client/tmpl/profile/credit.html",
directives: [ROUTER_DIRECTIVES]
})
模板:
<ul>
<li><a [routerLink]="['Profile' , 'Home']" href="#">home</a> </li>
</ul>
為什麼我應該在credit
Component裡面使用RouteConfig?以及如何使用?