Reputation: 4341
In angular2, given this code
<div id="{{window.id}}_body" class="session_body hidden">
<div class="tab" *ngFor="let bookmark of window.bookmarks; let i = index;" id="{{window.id}}_{{i}}_bookmark">
<bookmark [id]="window.id"+'_'+"i"+'_bookmark' [bookmark]="bookmark.url"></bookmark>
</div>
</div>
It fails because when I try to pass the variable [id]
<bookmark [id]="window.id"+'_'+"i"+'_bookmark' [bookmark]="bookmark.url">
I am not passing a simple variable, but a string that uses variables.
Can it be done? Or I should pass the variables "window.id" and "i" separately and then re-construct the id from this later on (which is what I'd like to avoid), like
<bookmark [id]="window.id" [index]="i" [bookmark]="bookmark.url">
Upvotes: 0
Views: 81
Reputation: 14077
It works.
You just got entangled in your simple/double quotes :
<bookmark [id]="window.id+'_'+i+'_bookmark'">
Upvotes: 1