jeudi 2 juillet 2015

Compute length of a model

I have this productsCount computed property which should count all products but it always returns a 0. Why is that and how can I fix it?

controller.js

productsCount: Ember.computed('model.products', function() {
  var products = this.get('model.products');
  return products.get('length');
}),

route.js

import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    return {
      products: this.store.find('product')
    };
  }
});




Aucun commentaire:

Enregistrer un commentaire