key:from
One-way bind a value in the parent scope to the ViewModel or element.
childProp:from="key"
Imports key in the scope to childProp
in viewModel. It also updates childProp
with the value of key
when key
changes.
<my-component someProp:from="value"/>
Note: If key is an object, changes to the object's properties will still be visible to the component. Objects are passed by reference. See One Way Binding With Objects.
Parameters
- childProp
{String}
:The name of the property to set in the component’s viewmodel.
- key
{Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}
:An expression whose resulting value is used to set as
childProp
.
child-prop:from="key"
Imports key in the scope to child-prop
property or attribute on the element.
<input value:from="name"/>
vm:childProp:from="key"
Imports key in the scope to childProp
in viewModel. It also updates childProp
with the value of key
when key
changes.
<my-component vm:childProp:from="key"/>
Note: If key is an object, changes to the object's properties will still be visible to the component. Objects are passed by reference. See One Way Binding With Objects.
Parameters are the same as childProp:from="key"
el:child-prop:from="key"
Imports key in the scope to child-prop
property or attribute on the element.
<input el:value:from="name"/>
Parameters are the same as child-prop:from="key"
Use
The can-stache-bindings page has many examples of key:from. Specifically: