I have a small web-app that accepts input
from a human to create search params. I'm using ng-model-options
to debounce the ng-change
function to execute the search.
I have small arrows next to the column names on the table that lets users sort (there are three icons - up-down
, up
, and down
for the sort_field and sort_order displayed using ng-class
) ; I would like to register a change on those and execute a search after a small delay using debounce. The problem is I'm not sure how use ng-model
to bind the particular param to those icons. I don't want someone hammering on the sort icons and crashing the server or their browser.
What I would rather do is have one place on the page that says to watch the search_param
object and fire a search 500 milliseconds after whenever it has changed. This way any of the input fields or sort selections would be called when a user is done editing them which triggers a function to send those params to the endpoint.
What is the strategy in AngularJS to do this? Right now all input fields bind a field in the search_param
object and have ng-model-options
to debounce on change. This is a lot of repeated code.