【问题标题】:Pass property to component and then used it as conditional (ember js)将属性传递给组件,然后将其用作条件(ember js)
【发布时间】:2015-06-27 08:33:38
【问题描述】:

应用程序控制器

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

组件

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

这是组件模板

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

我想使用该属性作为条件我该如何实现

【问题讨论】:

  • {{step-controller hotelPage=isHotel_profile}}

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


【解决方案1】:

您的代码是有效的,应该可以正常工作。

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

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

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

【讨论】:

    猜你喜欢
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多