0

I am using below library to use autocomplete directive in my module for AngularJS!. [https://github.com/JustGoscha/allmighty-autocomplete]

I want to execute a function when user has stopped typing, is there a way I can do this?

5
  • 1
    I'd imagine you could use ng-model-options specifically the debounce property. Dunno if it will work with that directive, but you can give it a try. Commented Mar 27, 2017 at 14:23
  • Use setTimeout() , and recreate it on every click. Commented Mar 27, 2017 at 14:29
  • 1
    According to the allmighty-autocomplete docs, there is an on-type attribute? Have you tried it? Commented Mar 27, 2017 at 14:30
  • ya i have used on-type property but i want to execute my fuction once typing has been stopped Commented Mar 27, 2017 at 14:31
  • You can possibly set a timeout in the function you are executing on the on-type event. It will get restarted every time the user types but won't if they stop typing. Commented Mar 27, 2017 at 14:37

1 Answer 1

4

You can do it using ng-change and ng-model-options (Angular 1.3+ only):

<input type="text"
       ng-model="myVar"
       ng-model-options="{debounce: 1000}"
       ng-change="functionToBeCalled()"/>
Sign up to request clarification or add additional context in comments.

2 Comments

@RajDubey "This doesn't work" does not mean anything. What is the behavior? Do you have any error? What is your Angular version?
actually by using this what i do is just delay the response. but what I want is when user is typing there should be a loader and it stops typing options are shown

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.