Sarath Dixit
Sarath Dixit

Reputation: 91

Angular navigation issue

When I click the whole card it should navigate to the project detail component and then when I click the BID RECEIVED button it should navigate to the bids component but it navigates to project detail page

<div class="card" *ngFor="let data of projectdata">
   <div class="card-body" routerLink="/projectdetail/{{data._id}}">
      <div class="bids" routerLink='/bids/5edbd6eb3290c300179cc2f9'>{{data.totalBids}} BIDS RECEIVED</div>
   </div>
</div>

Upvotes: 0

Views: 46

Answers (2)

Max21
Max21

Reputation: 315

Not sure it is a good practice to have nested RouterLinks, but this solution might work in your case: https://stackoverflow.com/a/53147466/12660773

Upvotes: 1

alex87
alex87

Reputation: 432

Try removing the router link on the bids div and replacing it with (click)=nav() and then in your .ts file:

import {Router} from '@angular/router';

constructor(private router: Router) {}

nav() {
    this.router.navigateByUrl('/bids/5edbd6eb3290c300179cc2f9');
}

Upvotes: 0

Related Questions