DoneJS StealJS jQuery++ FuncUnit DocumentJS
3.14.1
5.0.0 4.3.0 2.3.35
  • About
  • Guides
  • API Docs
  • Community
  • Contributing
  • Bitovi
    • Bitovi.com
    • Blog
    • Design
    • Development
    • Training
    • Open Source
    • About
    • Contact Us
  • About
  • Guides
  • API Docs
    • Observables
      • can-compute
      • can-define
      • can-define/list/list
      • can-define/map/map
      • can-define-stream
      • can-define-stream-kefir
      • can-event
      • can-event/async/async
      • can-event/batch/batch
      • can-event/lifecycle/lifecycle
      • can-kefir
      • can-list
      • can-map
      • can-map-backup
      • can-map-define
      • can-observation
      • can-observe
      • can-simple-map
      • can-simple-observable
      • can-stream
      • can-stream-kefir
    • Data Modeling
      • can-connect
      • can-connect-cloneable
      • can-connect-feathers
      • can-connect-ndjson
      • can-connect-signalr
      • can-fixture
      • can-fixture-socket
      • can-ndjson-stream
      • can-set
    • Views
      • can-component
      • can-ejs
      • can-element
      • can-react-component
      • can-stache
      • can-stache/helpers/route
      • can-stache-bindings
        • Syntaxes
          • on:event
          • toChild:from
          • toParent:to
          • twoWay:bind
          • can-stache-bindings.legacy-syntaxes
            • (event)
            • {to-child}
            • {^to-parent}
            • {(two-way)}
            • *REFERENCE
      • can-stache-converters
      • can-view-autorender
      • can-view-callbacks
      • can-view-href
      • can-view-import
      • can-view-live
      • can-view-model
      • can-view-nodelist
      • can-view-parser
      • can-view-scope
      • can-view-target
      • react-view-model
      • react-view-model/component
      • steal-stache
    • Routing
      • can-deparam
      • can-param
      • can-route
      • can-route-pushstate
    • JS Utilities
      • can-assign
      • can-define-lazy-value
      • can-globals
      • can-key-tree
      • can-make-map
      • can-parse-uri
      • can-string
      • can-string-to-any
      • can-util
      • can-zone
      • can-zone-storage
    • DOM Utilities
      • can-ajax
      • can-attribute-encoder
      • can-control
      • can-dom-events
      • can-event-dom-enter
      • can-event-dom-radiochange
      • can-jquery
    • Data Validation
      • can-define-validate-validatejs
      • can-validate
      • can-validate-interface
      • can-validate-legacy
      • can-validate-validatejs
    • Typed Data
      • can-cid
      • can-construct
      • can-construct-super
      • can-namespace
      • can-reflect
      • can-reflect-promise
      • can-types
    • Polyfills
      • can-symbol
      • can-vdom
    • Core
    • Infrastructure
      • can-global
      • can-test-helpers
    • Ecosystem
    • Legacy
  • Community
  • Contributing
  • GitHub
  • Twitter
  • Chat
  • Forum
  • News
Bitovi

{^to-parent}

  • Edit on GitHub

One-way bind a value in the current viewModel to the parent scope.

Deprecated 3.8

This syntax is deprecated in favor of childProp:to="key"

{^child-prop}="key"

Exports childProp in the ViewModel to key in the parent scope. It also updates key with the value of childProp when childProp changes.

<my-component {^some-prop}="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

  1. child-prop {String}:

    The name of the property to export from the child components viewmodel. Use {^this} or {^.} to export the entire viewModel.

  2. key {Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}:

    An expression that will be used to set in the parent scope.

{^$child-prop}="key"

Exports the element’s childProp property or attribute to key in the parent scope. It also updates key with the value of childProp when childProp changes.

<input {^$value}="name"/>

Parameters

  1. child-prop {String}:

    The name of the element’s property or attribute to export.

  2. key {Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}:

    An expression whose resulting value with be used to set in the parent scope.

Use

The use of {^to-parent} bindings changes between exporting viewModel properties or DOM properties.

Exporting ViewModel properties

{^child-prop}="key" can be used to export single values or the complete view model from a child component into the parent scope. Typically, the values are exported to the references scope.

In the following example, it connects the selected driver in <drivers-list> with an editable plateName in <edit-plate>:

<drivers-list {^selected}="*editing"/>
<edit-plate {(plate-name)}="*editing.licensePlate"/>

Exporting DOM properties

{^$child-prop}="key" can be used to export an attribute value into the scope. For example:

<input {^$value}="name"/>

Updates name in the scope when the <input> element’s value changes.

Exporting Functions

You can export a function to the parent scope with a binding like:

<my-tabs {^@add-panel}="@*addPanel">

And pass the method like:

<my-panel {add-panel}="@*addPanel" title="CanJS">CanJS Content</my-panel>

Check it out in this demo:

Notice that @ is used to prevent reading the function.

CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.14.1.

On this page

Get help

  • Chat with us
  • File an issue
  • Ask questions
  • Read latest news