vendredi 15 avril 2016

adding into model in init function of emberJS component

This is my ember.JS component:

export default Ember.Component.extend({
  ajax: Ember.inject.service('my-service'),
  init() {
    this._super.apply(this,arguments);
    this.get('ajax').getAllRestaurants().done(data => {
      this.set('model', data);
    });

  },
});

now as you can see, I created model, and that model consists of many restaurants. Is there a way to add one more property to each model element?

What I need exactly is this: I have rating property in each model element. I want to add 'stars' property to each model element and that 'stars' should contain HTML code with star signs (the bigger the rating, more stars). How can I do this in Ember.JS (I am using the latest version of Ember - 2.4.0)?




Aucun commentaire:

Enregistrer un commentaire