Reputation: 403
<div id="stage">
<div class="space-item"
*ngFor="let space of spaces; let i=index; trackBy:trackBySpaces"
routerLink="/space/{{space.space_id}}"
[ngStyle]="spaceStyles(positions[i].x, positions[i].y)"
>
{{space.space_id}}|{{space.name}}
</div>
</div>
In the code above, how could I do NOT set the routerLink attribute when the space.space_id is empty, I wish to have something like this.
if(space.space_id){routerLink="/space/{{space.space_id}}"}
but I cann't find any solution. Thanks in advance!
Upvotes: 2
Views: 923
Reputation: 657366
This can be used in template:
[routerLink]="space.space_id ? '/space/' + space.space_id : 'defaultUrl'"
Upvotes: 1