I have an input field where a user should be able to change his name. So can manipulate the field, and when terminated the new string should be stored as a new username? I tried to achieve that with form
but I get this error: Error: Template parse errors: Can't bind to 'formGroup' since it isn't a known property of 'form'
.
Here is my code
page.html
<form [formGroup]="form" (ngSubmit)="changeName()">
<ion-list no-border>
<ion-list-header>
My Account
</ion-list-header>
<ion-item >
<ion-input>{{username}}</ion-input>
</ion-item>
...
</ion-list>
</form>
page.ts
import { FormGroup, FormControl, Validators} from '@angular/forms';
...
form: FormGroup;
public usernameInput = '';
...
constructor() {}
...
changeName() {
this.usernameInput = '';
}
ngOnInit() {
this.form = new FormGroup({
username: new FormControl(null, {
updateOn: 'submit',
validators: [Validators.required, Validators.maxLength(20), Validators.minLength(1)]
})
});
}