Last active
January 5, 2016 14:25
-
-
Save hjumeau/4dae8abddab27ac0da8e to your computer and use it in GitHub Desktop.
cumputedPro
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
import Ember from 'ember'; | |
var Person = Ember.Object.extend({ | |
firstName: null, | |
lastName: null, | |
age: null, | |
country: null, | |
dateOfDeath: null, | |
fullName: Ember.computed('firstName', 'lastName', function() { | |
return `${this.get('firstName')} ${this.get('lastName')}`; | |
}), | |
isDead: Ember.computed('dateOfDeath', { | |
get(key) { | |
return !!this.get('dateOfDeath'); | |
}, | |
set(key, value) { | |
if (value) { | |
this.set('dateOfDeath', new Date()); | |
} else { | |
this.set('dateOfDeath', null); | |
} | |
return value; | |
} | |
}), | |
description: Ember.computed('fullName', 'age', 'country', function() { | |
return `${this.get('fullName')}; Age: ${this.get('age')}; Country: ${this.get('country')}`; | |
}) | |
}); | |
var captainAmerica = Person.create({ | |
firstName: 'Steve', | |
lastName: 'Rogers', | |
age: 80, | |
country: 'USA' | |
}); | |
//document.write(captainAmerica.get('description')); | |
//document.write('<br> is Dead = ' + captainAmerica.get('isDead')); | |
captainAmerica.set('isDead', true); | |
//document.write('<br> date of death ' + captainAmerica.get('dateOfDeath')); |
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
{ | |
"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.2.0", | |
"ember-data": "2.2.0", | |
"ember-template-compiler": "2.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment