key:bind
Two-way bind a value in the StacheElement, can-component ViewModel, or element to the parent scope.
childProp:bind="key"
Two-way binds childProp in the StacheElement or can-component ViewModel to
key in the parent scope. If childProp is updated key will be updated
and vice-versa.
<my-element someProp:bind="value" />
When setting up the binding:
- If
childPropisundefined,keywill be set tochildProp. - If
keyisundefined,childPropwill be set tokey. - If both
childPropandkeyare defined,keywill be set tochildProp.
Parameters
- childProp
{String}:The name of the property of the StacheElement or can-component ViewModel to two-way bind.
- key
{Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}:A call expression whose value will be used to two-way bind in the parent scope.
child-prop:bind="key"
Two-way binds the element’s child-prop property or attribute to
key in the parent scope. If child-prop is updated, key will be updated
and vice-versa.
<input value:bind="name" />
Parameters
- child-prop
{String}:The name of the element’s property or attribute to two-way bind.
- key
{Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}:A call expression whose value will be used to two-way bind in the parent scope.
vm:childProp:bind="key"
Two-way binds childProp in the StacheElement or can-component ViewModel to
key in the parent scope. If childProp is updated, key will be updated
and vice-versa.
<my-element vm:someProp:bind="value" />
When setting up the binding:
- If
childPropisundefined,keywill be set tochildProp. - If
keyisundefined,childPropwill be set tokey. - If both
childPropandkeyare defined,keywill be set tochildProp.
Parameters are the same as childProp:bind="key"
el:child-prop:bind="key"
Two-way binds the element’s child-prop property or attribute to
key in the parent scope. If child-prop is updated, key will be updated
and vice-versa.
<input el:value:bind="name" />
Parameters are the same as child-prop:bind="key"
Initialization
When a binding is being initialized, the behavior of what the component and scope properties are set to depends on their initial values:
- If the component’s property value is not
undefinedand the scope’s property isundefined, scope will be set to the component’s property value. - If the component’s property value is
undefinedand the scope’s property is notundefined, component’s property will be set to the scope value. - If both the component and scope properties are not
undefined, component’s property will be set to the scope value.