Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Last active February 29, 2016 21:15
Show Gist options
  • Save hjumeau/4b3f9ce940d49d09b289 to your computer and use it in GitHub Desktop.
Save hjumeau/4b3f9ce940d49d09b289 to your computer and use it in GitHub Desktop.
classesAndInstances
import Ember from 'ember';
var Person = Ember.Object.extend({
say(thing) {
var name = this.get('name');
alert(`${name} says: ${thing}`);
}
});
var Soldier = Person.extend({
say(thing) {
// this will call the method in the parent class (Person#say), appending
// the string ', sir!' to the variable `thing` passed in
this._super(`${thing}, sir!`);
}
});
var yehuda = Soldier.create({
name: 'Yehuda Katz'
});
yehuda.say('Yes');
yehuda.set('age', 34);
document.write(yehuda.get('age'));
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.3.1",
"ember-data": "2.3.3",
"ember-template-compiler": "2.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment