How to bind expressions to attributes when dynamically creating components

With markup I can do things like this:

 <aura:attribute name="level" type="Integer" />
 <c:childComponent level={!v.level + 1} />

I can bind expression to child’s attribute, and whenever attribute changes in parent component, it is automatically changed in child component. But I create component dynamically, so I pass attribute like this:

        "level": cmp.getReference("v.level")

So I can use cmp.getReference("v.level") to bind value or cmp.get("v.level") to get raw value. How can I achieve combination of binding with expression like in markup?


Source : Link , Question Author : Vladyslav K , Answer Author : Community

Leave a Comment