Skip to content

Instantly share code, notes, and snippets.

@slindberg
Last active December 8, 2016 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slindberg/95215479eac58e13d3c0 to your computer and use it in GitHub Desktop.
Save slindberg/95215479eac58e13d3c0 to your computer and use it in GitHub Desktop.
Two-way bindings and the `mut` helper in Ember
<div class="form-control">
<label>{{attrs.label}}</label>
{{! Since mutable attributes are now wrapped, this will no longer work :( }}
{{input value=attrs.value}}
{{! Instead, we need to leverage some kind of event... }}
{{input value=attrs.value.value key-up=attrs.value.update}}
{{! Or, forgo two-way bindings and the `input` helper altogether, which forces us to create an explicit action... }}
<input value={{attrs.value.value}} {{action 'updatedValue' on="change"}} />
</div>
{{! Let's create the basic two-way binding example using angle-bracket components}}
<form-control label="Enter value:" value={{mut text}} />
<p>Value: {{text}}</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment