Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

orderBy same property as ngModel throws $digest error #10014

Closed
alexreardon opened this issue Nov 12, 2014 · 4 comments
Closed

orderBy same property as ngModel throws $digest error #10014

alexreardon opened this issue Nov 12, 2014 · 4 comments

Comments

@alexreardon
Copy link

When I try to orderBy a property that I am binding to in a ng-repeat I get a $digest error.
I think it is occurring because in one digest the ng-model value is updating, which effects the parents orderBy clause. I do not know how to get around this.

Plunker

This shows the issue occurring. Be sure to open the console!
http://embed.plnkr.co/rGLagq/preview

JS

var options = [
    {
        name: 'test',
        isSelected: true
    }, 
    {
        name: 'another test',
        isSelected: false
    }
];

HTML

<div ng-repeat="option in options | orderBy:'-isSelected'">
        <label>
             <input type="checkbox"
                    ng-model="option.isSelected"> {{option.name}}
        </label>
    </div>

Error

Error: [$rootScope:inprog] $digest already in progress

Other

Original StackOverflow issue
http://stackoverflow.com/questions/26877936/angularjs-orderby-same-property-as-ngmodel-throws-digest-error

Angular Version
Occuring on 1.3.2 and 1.3.0. I have not checked versions previous to 1.3.0

@alexreardon alexreardon changed the title AngularJS orderBy same property as ngModel throws $digest error orderBy same property as ngModel throws $digest error Nov 12, 2014
@petebacondarwin petebacondarwin added this to the 1.3.4 milestone Nov 12, 2014
@petebacondarwin
Copy link
Contributor

This is a bug in the ngModelController, I believe. The unwanted apply is being called on the blur handler used to change the $touched property (https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L2466) We should be using $evalAsync.

Similar to 804e750

@Narretz
Copy link
Contributor

Narretz commented Nov 12, 2014

There's a PR for that: #9808 Let's add it to 1.3.4, shall we?

@petebacondarwin
Copy link
Contributor

Done!

@alexreardon
Copy link
Author

Thanks for sorting this one out guys! It now works great 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants