Issue
Do you know how to use the ternary operator with routerLink
?
Now it is like so:
<ion-button *ngIf="event?.evId"
routerLink="/event/event-details/{{event?.evId}}">
Cancel
</ion-button>
<ion-button *ngIf="!event?.evId" routerLink="/event"> Cancel
</ion-button>
I would like to use the ternary operator here and remove one section completely. How to do that?
Note
I can do that inside the TS file. But how to do that without using the TS file?
Solution
OP's
<ion-button [routerLink]="event?.evId ? '/event/event-details/'+ event?.evId : '/event'">
Cancel
</ion-button>
Original
You can bind to any attribute like this
[routerLink]="event?.evId != null ? '/event/event-details/'+event.evId : '/event' "
Answered By - Munzer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.