ng-bind + function

2,396 views
Skip to first unread message

samuel....@ouvanous.com

unread,
Jun 6, 2012, 9:41:32 AM6/6/12
to ang...@googlegroups.com
Hi, 

I am new to angular and would like to understand how i can achieve this. 

I use rdf.js as data model and want to do something like that http://jsfiddle.net/ouvanous/bDEYd/14/
When i did this i notice that the call to get method is done two times and i don't understand why ? 
Also i don't think that that this is the best way ? 
Thanks, by advance for any advice. 

Samuel 

Dan Doyon

unread,
Jun 6, 2012, 12:40:22 PM6/6/12
to ang...@googlegroups.com
Samuel, 

Would need a bit more context as to what you are trying to accomplish.  However, you do point out an interesting issue. I played around with your fiddle 


I added a second controller which checks the number of times the controller is called and if 'get' has been called more than once it returns at beginning of call. Interestingly, your original controller now gets called not twice but three times and adding the 'times' check prevents the view from rendering properly. 

Unless I'm missing something, there is no reason why you shouldn't be able to bind this way, in fact, it is encouraged.

I'm curious as to what the devs say

--dan


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/DPHqtpvf9X4J.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Misko Hevery

unread,
Jun 6, 2012, 8:10:59 PM6/6/12
to ang...@googlegroups.com
Read up on runtime section: http://ci.angularjs.org/job/angular.js-misko/580/artifact/build/pkg/1.0.0rc10/docs-1.0.0rc10/guide/concepts

Yes we call everting over and over until we are sure that the model is stable. That usually means 2 iterations. For this reason your getter function needs to be supper quick. If it is not, then you need to precompute the result and bind to the precomputed value.
Reply all
Reply to author
Forward
0 new messages