将属性传递给组件,然后将其用作条件(ember js)

时间:2015-06-27 08:33:39

标签: ember.js ember-cli ember-controllers ember-components

应用程序控制器

isHotel_profile: function (){
    return this.get('currentPath') === 'hotel';
}.property('currentPath'),

成分<​​/ P>

{{#step-controller hotelPage=isHotel_profile}} {{/step-controller}}

这是组件模板

{{#if hotelPage}}
 hotel page 
{{else}}
 not hotel page
{{/if}}

我想将该属性用作条件,我该如何实现

1 个答案:

答案 0 :(得分:2)

您的代码有效且应该可以正常使用。

这是一个演示:http://emberjs.jsbin.com/nesete/1/edit?html,js,output

请注意,您可以像这样简化计算属性:

isHotel_profile: Ember.computed.equal('currentPath', 'hotel')