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?
Try this construction
<input [ngModel]="getMyProperty()"></input>
- use only square brackets.
来源:https://stackoverflow.com/questions/39468450/ngmodel-with-a-bind-function-not-working-in-ng2