angular - How to use expression for (click) event -
in angular2 have multiple buttons , on click set value. possible use expression in click event ie., instead of calling function can set value directly?
<button (click)="setvalue(1)">1</button> <button (click)="setvalue(1)">2</button> <button (click)="setvalue(1)">3</button>
to thing like
<button (click)="{{value=1}}">1</button> <button (click)="{{value=1}}">2</button> <button (click)="{{value=1}}">3</button>
you can use expressions don't use {{}}
<button (click)="value=1">1</button>
angular evaluates value part when attribute name wrapped in []
, ()
(or both [()]
or when value contains {{}}
. don't use []
, ()
{{}}
.
{{}}
stringifies result. if want bind non-string values properties don't use {{}}
@ all.
Comments
Post a Comment