2

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?

1
  • 2
    If getValue() is simply return value; there'd be very little difference. Commented Jul 31, 2014 at 9:23

2 Answers 2

0

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 .

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.