SuperHero = Ember.Object.extend({
firstName: '',
lastName: ''
});
var ironMan = SuperHero.create({
firstName: 'Tony',
lastName: 'Stark'
});
console.log(ironMan.get('firstName')); // Tony
console.log(ironMan.get('lastName')); // Stark
SuperHero = Ember.Object.extend({
firstName: '',
lastName: '',
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
});
var ironMan = SuperHero.create({
firstName: 'Tony',
lastName: 'Stark'
});
console.log(ironMan.get('lastName')); // Tony Stark
SuperHero = Ember.Object.extend({
firstName: '',
lastName: '',
lastNameChanged: function() {
console.log('lastNameChanged fired!');
}.observes('lastName')
});
var ironMan = SuperHero.create({
firstName: 'Tony',
lastName: 'Stark'
});
ironMan.set('lastName', 'Shark'); // lastNameChanged fired!