ga-wdi-boston / ember-object

Explore the Ember Object Model, and leverage it to do some basic binding through computed properties.
Other
1 stars 112 forks source link

Consider replacing last computed properties example with "Bob's Burgers" one? #3

Closed GA-MEB closed 8 years ago

GA-MEB commented 8 years ago
var Person = Ember.Object.extend({
  fullName: Ember.computed('givenName', 'surname', function(){
    return this.get('givenName') + ' ' + this.get('surname');
  }),
  isOverFifty: Ember.computed.gte('age', 50),
  isABelcher: Ember.computed.equal('surname', 'Belcher'),
  hasNickname: Ember.computed.notEmpty('nickname'),
  kidsWithLongerNames: Ember.computed.filter('kids.@each.name', function(kid){
    return kid.get('name').length > 4;
  })
});

var gene = Ember.Object.create({
  name: 'Gene',
  age: 9
});
var tina = Ember.Object.create({
  name: 'Tina',
  age: 14
});
var louise = Ember.Object.create({
  name: 'Louise',
  age: 7
})

var bob = Person.create({
  givenName: 'Bob',
  surname: 'Belcher',
  age: 45,
  kids: [gene, tina, louise]
})