Reputation: 189
I get error on my code with angular 6
<span *ngFor="let tag of item.payload.doc.data().TAGS" >
<button class="nav-link active" (click)="searchByTags('{{tag}}')" >{{tag}},</button>
</span>
I want to have dynamic {{tag}} into searchByTags function but it gives me next error:
Parser Error: Got interpolation ({{}}) where expression was expected at column 14 in [searchByTags('{{tag}}')] in ng:///AppModule/HomeComponent.html@76:56 ("et tag of item.payload.doc.data().TAGS" >
<button class="nav-link active" [ERROR ->](click)="searchByTags('{{tag}}')" >{{tag}},</button>
</span>
Upvotes: 1
Views: 3738
Reputation: 2600
Change your code to this:
<span *ngFor="let tag of item.payload.doc.data().TAGS" >
<button class="nav-link active" (click)="searchByTags(tag)" >{{tag}},</button>
</span>
You do not need to interpolate the tag value inside the click handler. You can directly pass the value without interpolation.
Upvotes: 2