• Blogs (9)
    • 📱 236 - 992 - 3846

      đź“§ jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • AngularJS performance: ng-repeat:: - double colon

    Blogs20152015-07-08


    AngularJS ng-repeat:: - double colon

    I was struggled with ng-repeat performance when using multi-select. If the items is large, let’s say, over 2000, the angular-multi-select stuck there coz of to create new scope and individual-item-$watch processing.

    I used service-cache, indexeddb, typeAhead, removing ng-bind-html, $sce to try to speed-up the rendering, but effects are not good. Finally I found the solution is to make item readonly, to prevent item-$watch in ng-repeat.

    <ul>
        <li ng-repeat="item in ::items">{{::item.name}}</li>
    </ul>

    double colon(::) is important here to prevent Angular to watch(item, callback) for each item when create new scope. There is an option bindonce, I will use in the future, probably.