0

I am developing a travel site in that need to display list of available buses data based on from and to places by clicking the search button in angular, but i am getting searched data based on the search filter pipe in search box but i need to display the data by clicking the search button only.

  • Please, provide a concrete question of what your issue is - what the actual problem is, what have you tried already? Possible provide a stackblitz repro. – TotallyNewb Sep 18 '20 at 08:07
  • you can check this : https://stackoverflow.com/questions/41386133/angular-filter-table-using-custom-pipe-upon-button-click?noredirect=1&lq=1 – Nish007 Sep 18 '20 at 09:27

2 Answers2

0

According to your question you have used search pipe for searching functionality. Since you have used pipe it will filter on every change of input field but you want it to be searched only when user clicks search button. For that if you are using your own custom pipe then you can add some logic there during filter like if it is custom search pipe you may have used ngOnchanges hook in that you can check some parameter like user requested etc and then according to that you can perform search in that pipe.

Happy Coding!

SaiSurya
  • 1,046
  • 8
  • 14
0

You may want to try this: Bind the search input to searchText variable and use filterText variable in your pipe. When user clicks on search button, only then replace filterText with searchText like this:

filterText = searchText;

This will prevent the filtering of your data on users every key stroke. You decide to change when to filter by explicitly assigning the searched text to filter text.

Happy Coding.