我有一个父组件(配置文件),在这个组件中,我有购物篮路线(配置文件/购物篮),这是我的购物篮组件:
export class basket extends Ext implements OnDestroy{
private ShopItems_Movies : Array<{}> = [];
private ShopItems_Music : Array<{}> = [];
subscriptions : Subscription[] = [];
constructor(private _util: UtilService,private _shareService : shareService , private _Router : Router){
super();
this.subscriptions.push(_shareService.ShopItemSS$_.subscribe((items) =>{
console.log(items);
this.ShopItems_Movies = this.ext.givemelist(items ,{_type : "video"});
this.ShopItems_Music = this.ext.givemelist(items ,{_type : "music"});
}));
}
}
和我的模板:
<a [routerLink]="[item._type == 'video' ? 'Watch' : 'Listen', {uuid: item.item.uuid}]" class="btn-block right-align">
<div class="circle item_small_like_icon2 background_standard middle inline-block" [ngStyle]="{'background-image': 'url(' + _util.storageUrl(item.item.thumbnail) + ')'}">
</div>
<p class="black-text right-align middle inline-block margin-right-5">{{item.title}}</p>
</a>
和父路由配置:
@RouteConfig([
{name: 'Basket', component: basket ,path: '/basket' }
])
我的问题是,当我想在购物篮模板中使用
[routerLink]
时,抛出以下错误:platform-browser.umd.js:962 ORIGINAL EXCEPTION: Component "basket" has no route config.
我没有任何孩子在篮子里!有另一个孩子组件和routeLink,在该模板中可以正常使用!但是在这个组件中,我找不到我的问题!
最佳答案
今天已经有一个类似的问题以这种方式起作用:
<a [routerLink]="item._type == 'video' ? ['Watch', {uuid: item.item.uuid}] : ['Listen', {uuid: item.item.uuid}]" class="btn-block right-align">
关于javascript - 子路由中的routerLink错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37701403/