Created
April 22, 2012 15:34
-
-
Save SantoshSrinivas79/2464670 to your computer and use it in GitHub Desktop.
Learning-Emberjs-Post-2
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
// 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" |
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
<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