Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a string to Angular 2 (click) function?

I have a div element in my HTML like so

<div (click) = onPaginationClick()>next</div>

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

<div (click)=onPaginationClick("myString")>next</div>

I have a parse template error.

Enyone can help ?

like image 737
Nacim Idjakirene Avatar asked Aug 09 '16 11:08

Nacim Idjakirene


2 Answers

You need to wrap the whole expression in quotes if it itself contains quotes:

<div (click)="onPaginationClick('myString')">next</div>
like image 189
Günter Zöchbauer Avatar answered Nov 03 '22 12:11

Günter Zöchbauer


you need to use nested quotes:

<div (click)="onPaginationClick('helloworld')">next</div>
like image 2
Oliver Renner Avatar answered Nov 03 '22 13:11

Oliver Renner