Leo Messi
Leo Messi

Reputation: 6166

Make input checkbox update when clicked, not when data is done

There is an input checkbox which can be clicked to be checked or unchecked:

<input
    type="checkbox" 
    ng-model="$ctrl.checkedOrNot"
    ng-change="$ctrl.doSomething()"
/>

doSomething() {
    this.MyService.setInput(this.checkedOrNot);
    if(this.loading) return;
    this.doStuff();
    this.doOtherStuff();
}

For the moment the check appears only after all the calls from doSomething are done. Is there a way to make it appear right when it's clicked?

Upvotes: 0

Views: 33

Answers (1)

Emanuele
Emanuele

Reputation: 814

If you are using angular 1.3.x or above you can use ng-model-options to limit the amount of $digest cycles by setting a debounce value up to 0.

Take a look here

Upvotes: 1

Related Questions