1

There are big datasets and I want to search some data in it. When I wrote some strings in textbox it will submit or $watch for every single letter I wrote in the input. How can I optimize it? Is there any directive or object for this in angularjs? I consider I can handle it with the setTimeout function. When user stops writing I can call $watch function. Is there any easy or right way to do it with angularjs?

1

1 Answer 1

2

You can use ng-model-options directive to adjust your model custom behavior. Use properties updateOn and debounce (delay). For instance:

ng-model-options="{
  updateOn: 'default blur',
  debounce: { 'default': 500, 'blur': 0 }
}"// 500ms delay for default event and no delay for 'blur' event

Here is the article about it in the official docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.