adding into model in init function of emberJS component

时间:2016-04-15 15:17:34

标签: javascript jquery ember.js components

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)?

0 个答案:

没有答案