Created
September 5, 2013 18:14
-
-
Save twokul/6453933 to your computer and use it in GitHub Desktop.
cp-set
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
App.Person = Ember.Object.extend({ | |
firstName: null, | |
lastName: null, | |
fullName: function(key, value, oldValue) { | |
// setter | |
if (arguments.length > 1) { | |
var nameParts = fullNameString.split(/\s+/); | |
this.set('firstName', nameParts[0]); | |
this.set('lastName', nameParts[1]); | |
} | |
// getter | |
return this.get('firstName') + ' ' + this.get('lastName'); | |
}.property('firstName', 'lastName') | |
}); | |
var ironMan = Person.create({ | |
firstName: "Tony", | |
lastName: "Stark" | |
}); | |
ironMan.get('fullName'); // Tony Stark | |
ironMan.set('fullName', "William Burnside"); | |
ironMan.get('fullName'); // William Burnside |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment