what is ngModel without brackets and parentheses and when to use it?
<input name="name" ngModel>
I know [ngModel] is syntax for one-way bindning and [(ngModel)] is two-way bindning but what does it mean when you write without any brackets and parentheses?
2
Answers
NgModel
is just a directive.From Angular documentation:
If you put it into HTML element, it just brings all methods of this class to the element. Thus means you can use it with your needs, for example get
change
event –(ngModelChange)
.Small example:
This input has no initial value, but will emit event on change.
<input name="name" [(ngModel)]="propertyName">