toChild: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 objects 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"/>
This signature works, but the following should be used instead:
<input value="{{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:someProp:from="key"/>
Note: If key is an object, changes to the objects 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"/>
This signature works, but the following should be used instead:
<input value="{{name}}"/>
Parameters are the same as child-prop:from="key"
Use
childProp:from="key"
is used to pass values from the scope to a component.
You can use call expressions like:
<player-scores scores:from="game.scoresForPlayer('Alison')"/>
<player-scores scores:from="game.scoresForPlayer('Jeff')"/>