Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngModel with a bind function not working in ng2

If I do in a template of a component something like:

<input [(ngModel)]="myProperty"></input>

then it works, but if I do it with a function in my component it does not:

<input [(ngModel)]="getMyProperty()"></input>

Here is the plunkr. Tested on RC6. Why?

like image 287
lqbweb Avatar asked Sep 13 '16 11:09

lqbweb


1 Answers

Try this construction

<input [ngModel]="getMyProperty()"></input>
  • use only square brackets.
like image 178
Limitrof Avatar answered Sep 28 '22 00:09

Limitrof