Rahul Dagli
Rahul Dagli

Reputation: 4502

How to pass variable in angular 4 as an argument?

I have a div element in my HTML like so

<div (click) = onPaginationClick() *ngFor="let section of sections">next</div>

My question is : How to pass a variable to the onPaginationlick() function ? when I try to pass it like this :

<div (click)=onPaginationClick({{section.id}}) *ngFor="let section of sections">next</div>

I'm getting a parse template error.

Upvotes: 1

Views: 56

Answers (1)

yurzui
yurzui

Reputation: 214175

Don't use (...) and {{...}} together:

(click)="onPaginationClick(section.id)"

Upvotes: 3

Related Questions