Skip to content Skip to sidebar Skip to footer

Angularjs Ng-repeat Rerender

I'm building a simple app with AngularJS. The app make a async AJAX call to the server and the server returns an array like this: { paragraphs: [ {content: 'content one

Solution 1:

Angular doesn't know you've changed the array. Executing your sort inside a scope.$apply() will address that.

Note that I've added a that variable since this changes meaning inside the apply.

var that = this;
scope.$apply(function() {   
   StorageService.sort($(that).sortable("toArray"));
}

But that fix uncovers other problems that appear to be caused by the interaction between the jQuery sortable and Angular (here's a fiddle that shows an attempt at resolving the problems but still has issues). These issues have been solved in Angular UI Sortable. So a good path forward may be to switch to this.

Post a Comment for "Angularjs Ng-repeat Rerender"