I'm trying to make a search engine, which basically is a form with an input and a button. I want that when writing in the input and when giving enter, I send the parameter my typescript module. without it recharging. I am a beginner in angular 4.
This is the form of my view ..
<form class="form-inline my-2 my-lg-0" >
<input class="form-control mr-sm-2" type="search" placeholder="Buscar Héroe" aria-label="Search" (keyup.enter)="buscarHeroe(buscarTexto.value)" #buscarTexto>
<button (click)="buscarHeroe(buscarTexto.value)" class="btn btn-outline-success my-2 my-sm-0" type="button">Buscar</button>
</form>
I'm trying to get the value to be received nothing more, just to test.
this is the function of my typescript component
buscarHeroe(termino:string){
console.log(termino);
}
Yes, I do not know if it's the right way, I'm missing something? by pressing the button, if it works. but when writing in the input and give enter. this refreshes the page. I await your response!