I have this 'Username' input:
<div class="form-group">
<label for="userName">Username</label>
<input name='userName' ngModel id="userName" type="text"
ng-model="userName" init="userName='Bob'" value="Bob" >
</div>
I want to set the input to 'Bob' by default but this doesn't work. If i delete 'ngModel' it works and I need it otherwise it won't sent my username to server.
This is in the begging of the form(the action that happens when I press submit button):
<form #physicians="ngForm" (ngSubmit)="onFormSubmit(physicians.value)">
And this the controller:
onFormSubmit(data) {
console.log(data);
this.adminService.updateUser(data).subscribe((responseData: any) => {
this.router.navigate(['/']);
},
(err: HttpErrorResponse) => {
this.isSignupError = true;
this.errorText = err.error['message'];
});
}
How can I fix this?Thank you!