为什么我的Ember "if" 没有调用关联函数?
My Ember "if" is not calling the associated function why?
我的 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')
我的 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')