I have been struggling with what seems like a simple question, but none of the solutions I found seem to work for me. In my component.html file, I have a standard input field:
<div class="form-group">
<label>Serial</label>
<input type="text" name="serial" id="serial" [ngModel]="serial" [value]="serial" class="form-control">
</div>
When the user submits the form, how do I retrieve the value they typed into the field? If I try console.log(this.serial)
in my onSubmit()
function, it logs nothing. I have declared serial: String;
in my component.ts file.