Last active
August 29, 2015 14:22
-
-
Save kalyco/f980cc1d0072b74eb06d to your computer and use it in GitHub Desktop.
Binds the field to a property in the controller and lets Ember handle keeping things updated. In this example a controller is set up with 2 properties 'number' and 'timesTwo'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in the controller | |
App.NumberController = Ember.ObjectController.extend({ | |
number: 1, | |
timesTwo: function() { | |
return Number(this.get('number')) * 2; | |
}.property('number') //tells it to treat it as a dynamic property that updates whenever number updates. | |
}); | |
//in the template | |
{{input type="text" value=number size=50}} x2 = {{timesTwo}} | |
//because we are able to bind properties in templates, | |
//we don't have to worry about making sure every event updates every | |
// field that might be affected. | |
//You just update the part you want and let Ember handle the rest. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment