Alireza Valizade Alireza Valizade - 1 month ago 9
Javascript Question

routerLink error in child route

I have a parent component (profile) and in this component i have Basket route (profile / basket) , this is my Basket component :

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"});


}));

}


}


and my template :

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


and parent route config :

@RouteConfig([


{name: 'Basket', component: basket ,path: '/basket' }
])


my problem is when i want use
[routerLink]
in basket template throw this erorr :
platform-browser.umd.js:962 ORIGINAL EXCEPTION: Component "basket" has no route config.

i dont have any child in basket!!have another child component and routeLink without any problem its ok in that templates!but in this component i cant find my problem!

Answer

There was a similar question already today where it worked this way:

<a [routerLink]="item._type == 'video' ? ['Watch', {uuid: item.item.uuid}] : ['Listen', {uuid: item.item.uuid}]" class="btn-block right-align">