Skip to content

Instantly share code, notes, and snippets.

@SantoshSrinivas79
Created April 22, 2012 15:34
Show Gist options
  • Save SantoshSrinivas79/2464670 to your computer and use it in GitHub Desktop.
Save SantoshSrinivas79/2464670 to your computer and use it in GitHub Desktop.
Learning-Emberjs-Post-2
// Now trying out the Barack Obama Example from emberjs.com
var MyApp = Ember.Application.create();
MyApp.president = Ember.Object.create({
firstName: "Barack",
lastName: "Obama",
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
// Tell Ember that this computed property depends on firstName
// and lastName
}.property()
});
MyApp.country = Ember.Object.create({
// Ending a property with 'Binding' tells Ember to
// create a binding to the presidentName property.
presidentNameBinding: 'MyApp.president.fullName'
});
// Later, after Ember has resolved bindings...
MyApp.country.get('presidentName');
// "Barack Obama"
<script type="text/javascript" src="http://dl.dropbox.com/u/10439810/ember/my_trials/js/libs/ember-0.9.7.1.min.js"></script>
<script type="text/javascript" src="http://dl.dropbox.com/u/10439810/ember/my_trials/post2/app.js"></script>
<div class="alert alert-info">
<script type="text/x-handlebars">
{{noparse}}
The President of the United States is {{MyApp.president.fullName}}.
{{/noparse}}
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment