我的徽章;如果“;为什么没有调用关联的函数

My Ember "if" is not calling the associated function why?

本文关键字:调用 关联 函数 为什么 徽章 如果 我的      更新时间:2023-09-26

我的html文件中有这个if语句:

{{#if statusIsCreated}}
     <button class="btn btn-success" {{action toggleProp}}>Edit</button>
{{/if}}

这个在我的控制器上:

    statusIsCreated: function () {
       if (this.get('model').get('status') === 'Created') {
            return true;    
       }
},

它应该做的是,当调用此模板时,它将检查属性状态的值是否为"Created",如果是,则会显示一个按钮。

我试着调试它,发现它甚至没有到达控制器上的if语句。。。知道为什么吗?

使statusIsCreated成为计算属性:

statusIsCreated: function () {
   if (this.get('model').get('status') === 'Created') {
        return true;    
   }
}.property('model.status')