can-stache-bindings
Version:
Default binding syntaxes for can-stache
59 lines (35 loc) • 2.74 kB
Markdown
in the [can-view-scope scope] to `childProp` in the [can-stache-element StacheElement] or [can-component.prototype.view-model can-component ViewModel]. It also updates `childProp` with the value of `key` when `key` changes.
```html
<my-element someProp:from="value" />
```
> __Note:__ If [can-stache.key] is an object, changes to the object’s properties will still be visible to the component. Objects are passed by reference. See [can-stache-bindings#OneWayBindingWithObjects One Way Binding With Objects].
[can-stache-element StacheElement] or [can-component.prototype.ViewModel can-component ViewModel].
Imports [can-stache.key] in the [can-view-scope scope] to `child-prop` property or attribute on the element.
```html
<input value:from="name" />
```
Imports [can-stache.key] in the [can-view-scope scope] to `childProp` in the [can-stache-element StacheElement] or [can-component.prototype.view-model can-component ViewModel]. It also updates `childProp` with the value of `key` when `key` changes.
```html
<my-element vm:childProp:from="key" />
```
> __Note:__ If [can-stache.key] is an object, changes to the object’s properties will still be visible to the component. Objects are passed by reference. See [can-stache-bindings#OneWayBindingWithObjects One Way Binding With Objects].
Parameters are the same as [can-stache-bindings.toChild#childProp_from__key_ childProp:from="key"]
Imports [can-stache.key] in the [can-view-scope scope] to `child-prop` property or attribute on the element.
```html
<input el:value:from="name" />
```
Parameters are the same as [can-stache-bindings.toChild#child_prop_from__key_ child-prop:from="key"]
## Use
The [can-stache-bindings] page has many examples of [can-stache-bindings.toChild]. Specifically:
- [can-stache-bindings#Updateanelement_svaluefromthescope Update a component ViewModel’s value from the scope]
- [can-stache-bindings#UpdateacomponentViewModel_svaluefromthescope Pass a value from an element to the scope]
Imports [can-stache.key]