Search code examples
javascriptangularjsweb-componentangular-components

Which Angular 1.5 component binding type is more expensive? '=' or '<'?


If I have a component and I have bound some variables to it - ignoring use cases for uni and bidirectional flow - which is more computationally expensive? = or <?

I initially though < would be cheaper as we don't need to propagate changes upwards, however considering the copy needed surely = would be beneficial most times since it'll just pass the reference through?

Or is it just related to the need for $onChanges?


Solution

    1. '=' passes link, of course it is cheapest and simplest way. (In i.e. Java you always pass link.)

    2. The problem is that you can not make this object or some its properties unmodifiable, you can not create interface or smth. Imagine hierarchy: <component-a object="object"><component-b object="object"><component-c object="object">

      Now you want to understand wtf is going here - who is setting or using what property - and you simply can not do it.

    3. What I feel now: -for simple objects use '<', can use onChanges, looks nice. -for big, complicated objects use '=' (of course, do not pass functions within it)