Angular 4 - get input value
In HTML add
<input (keyup)="onKey($event)">
And in component Add
onKey(event) {const inputValue = event.target.value;}
html
<input type="hidden" #fondovalor value="valores">
<button (click)="getFotoFondo()">Obtener</button>
ts
@ViewChild('fondovalor') fondovalor:ElementRef;
getFotoFondo(){
const valueInput = this.fondovalor.nativeElement.value
}
<form (submit)="onSubmit()">
<input [(ngModel)]="playerName">
</form>
let playerName: string;
onSubmit() {
return this.playerName;
}
If you dont want to use two way data binding. You can do this.
In HTML
<form (ngSubmit)="onSubmit($event)">
<input name="player" value="Name">
</form>
In component
onSubmit(event: any) {
return event.target.player.value;
}