I am trying to improve performance on an angularJS app. my colleague told me that this....
<div ng-bind="getValue()"></div>
//where this returns 'value'
Is less performant than this...
<div ng-bind="value"></div>
Is this true? If so why?
I am trying to improve performance on an angularJS app. my colleague told me that this....
<div ng-bind="getValue()"></div>
//where this returns 'value'
Is less performant than this...
<div ng-bind="value"></div>
Is this true? If so why?
If your function simply return a value, and doesn't accept any parameters, then it's not a good practice to to so: let's say you want to change that value later on, as a result of some function or user action.
this only makes sense if it is one way binding. as it is a function and you don't need to watch/observe the changes might have some benefits but then there is a binding called one-way binding in ng. It would be wiser if you use it.
Edit: it is called one-time binding and only available AngularJS 1.3. But there is a good SO Question for it and alternative approach for 1.2, also have a very simple comparison .