jeudi 5 février 2015

Shorthand computed properties

Can anyone please explain why these don't evaluate to the same thing?



Ember.ArrayController.extend({
maxProducts: 5,

hasMaxProducts: function () {
return this.get('model.length') === this.get('maxProducts');
}.property('model.length'),

shorthandHasMaxProducts: Ember.computed.equal('model.length', 'maxProducts')
});


I'm using the hasMaxProducts property in a handlebars template successfully, and if I try switching to the shorthandHasMaxProducts property, I don't get the same results, nor does it seem that this property ever updates. This should happen when I add another model to the array collection. I've also tried computing with:



Ember.computed.equal('model.[]', 'maxProducts')
Ember.computed.equal('model.[].length', 'maxProducts')




Aucun commentaire:

Enregistrer un commentaire