2

I tried to make a search system like this

<input type="text" class="form-control" placeholder="search product)" #searchValue/>
<span class="input-group-btn">
  <button class="btn btn-green" [routerLink]="['/search-result']" [queryParams]="{ q: searchValue.value}" >
    <i class="fa fa-search fa-md"></i>
  </button>
</span>

Assume than I already write 'Search' in the input tag and then I click the button. The result url

/search-result?q=

If I clicked again it will give a right url

/search-result?q=Search

If I change the input value (Search) before I click the button again, example I change it into 'Searching'. The result is

/search-result?q=Search

and need to clicked once again to get

/search-result?q=Searching

So it overdue by one request. Why is this happening? I tried to move the [routerLink] to span tag but it still the same. Any Idea how to fix it?

Thanks :)

AT82
  • 71,416
  • 24
  • 140
  • 167
Irvan
  • 165
  • 1
  • 13
  • Did you ever solve this? I'm having an issue now with my Angular solution! – EGC May 09 '21 at 06:56
  • @EGC Sorry for late notice. Nope, luckily for me its just an example project which I didn't have to fix – Irvan Jun 01 '21 at 11:47

0 Answers0