Tengo un formulario, donde en el input tengo asignado el [(ngModel)]= "authorValue"
, pero recibo "undefined" como valor.
authorValue: string;
createAuthor(event: Event){
event.preventDefault();
// aca recibo undefined
console.log('input value: ' + this.authorValue);
this.author.name = this.authorValue;
this.authorService.createAuthor(this.author);
this.authorService.createAuthor(this.author).subscribe(
res => {
console.log('autor guardado: ' + res);
},
err => console.error(err)
);
}
aca el formulario
<form (ngSubmit)="createAuthor($event)">
<div class="form-group">
<label>Nombre de autor</label>
<input type="text" class="form-control" [(ngModel)]="authorValue" placeholder="Ingrese nombre de autor">
<button type="submit" class="btn btn-block">Guardar</button>
</div>
</form>