I would like to use ngModel in my form in Angular. So I created two inputs:
<form class="form" action="#" method="post" onsubmit="#" autocomplete="on">
<div class="form__container">
<div class="input__container">
<input class="input" type="text" autofocus placeholder="E-mail address or phone number" [(ngModel)]="login">
</div>
<div class="input__container">
<input class="input" type="password" placeholder="Password" [(ngModel)]="password">
</div>
</div>
</form>
And code in class:
export class LoginFormComponent implements OnInit {
login:string='';
password:string='';
constructor() { }
ngOnInit(): void {
}
}
When I try to do two-way binding I am getting an error:
Can't bind to 'ngModel' since it isn't a known property of 'input'.
<input class="input" type="password" placeholder="Password" [(ngModel)]="password">
And also I got next error: Type 'Event' is not assignable to type 'string'. <input class="input" type="password" placeholder="Password" [(ngModel)]="password">
Why it happened? Thank you for any help.