Alireza Valizade Alireza Valizade - 3 years ago 108
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){

this.subscriptions.push(_shareService.ShopItemSS$_.subscribe((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) + ')'}">
<p class="black-text right-align middle inline-block margin-right-5">{{item.title}}</p>

and parent route config :


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

my problem is when i want use
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 Source

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">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download