how to access properties passed to Ember Component inside a component-class?

穿精又带淫゛_ 提交于 2019-12-04 11:27:53

It should work this way:

{{custom-component object_name=object}}

(you just used the wrong property name).

This should work if object is the object name. If name is a property of object then use object.name.


UPDATE

This should be straightforward. show_details should be defined as computed property depending on the object type:

App.CustomComponentComponent = Ember.Component.extend({
    object: null,
    show_details: function() {
      var object = this.get('object');
      if (object.get('type') === "AUTHORIZED")
         return true;
      else
         return false;
    }.property('object.type') 
});

or simpler:

App.CustomComponentComponent = Ember.Component.extend({
    show_details: function() {
      return this.get('object').get('type') === "AUTHORIZED";
    }.property('object.type') 
});

Don't forget to use get when accessing the properties of an Ember object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!