DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
      • Syntaxes
        • (event)
        • {to-child}
        • {^to-parent}
        • {(two-way)}
        • *REFERENCE
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-stache-bindings
  • /
  • {to-child}
  • / On this page
    • {to-child}

      function

      One-way bind a value in the parent scope to the [can-component::viewModel viewModel].

      • source

      {child-prop}="key"

      Imports key in the scope to childProp in [can-component::viewModel viewModel]. It also updates childProp with the value of key when key changes.

      <my-component {some-prop}="value"/>
      

      Parameters

      1. child-prop {String}:

        The name of the property to set in the component's viewmodel.

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

        An expression whose resulting value is used to set as childProp.

      {$child-prop}="key"

      Imports key in the scope to childProp property or attribute on the element.

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

      This signature works, but the following should be used instead:

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

      Use

      {child-prop}="key" is used to pass values from the scope to a component. You can use CallExpressions like:

      <player-scores {scores}="game.scoresForPlayer('Alison')"/>
      <player-scores {scores}="game.scoresForPlayer('Jeff')"/>
      

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