AngularJS - Upgrading v1.2.5 to 1.3 to use bind once

8.7k views Asked by At

I am trying to improve the performance of my ng-repeat's. I have upgraded my project to use library v1.3.0 (main lib and route).

I am trying to use the bind once as here: Do bindings nested inside of a lazy one-time ng-repeat binding bind just once?

However, when i add :: to my ng-repeat, the list is not populated:

<li ng-repeat="info in Profile.ChangeInfo">                 
    <p> {[{info.Message}]} </p>
</li>

The above works.

The below fails:

<li ng-repeat="info in ::Profile.ChangeInfo">                   
    <p> {[{::info.Message}]} </p>
</li>

Error i see is:

Error: [$parse:syntax] http://errors.angularjs.org/1.3.0-beta.9/$parse/syntax?p0=%3A&p1=not%20a%20primary%20expression&p2=1&p3=%3A%3AProfile.ChangeInfo&p4=%3A%3AProfile.ChangeInfo

UPDATE Upgraded to beta 16, and now seeing this error in IE8:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MS-RTC LM 8; InfoPath.3) Timestamp: Fri, 15 Aug 2014 12:01:03 UTC

Message: [$injector:modulerr] Failed to instantiate module ng due to:
Object doesn't support this property or method
http://errors.angularjs.org/1.3.0-beta.16/$injector/modulerr?p0=ng&p1=Object%20doesn't%20support%20this%20property%20or%20method
Line: 3982
Char: 7
Code: 0
URI: http://local host:1010/js/vendor/angular.js
2

There are 2 answers

4
runTarm On BEST ANSWER

The bindonce syntax :: has been introduced since angularjs version 1.3.0-beta.16

You have to upgrade angularjs to version 1.3.0-beta.16 or newer.

6
sylwester On

please see here sample demo http://jsbin.com/wimon/2/edit

Use the latest angularjs beta

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.18/angular.min.js"></script>

Remove square bracket

<li ng-repeat="info in ::Profile.ChangeInfo">                   
    <p> {{::info.Message}} </p>
</li>