【发布时间】:2013-12-29 06:15:53
【问题描述】:
我正在尝试使用模型中的计算属性来呈现模板中的数据。这是我的模型的 sn-p:
App.ApplicationRoute = Ember.Route.extend({
model: function() {
...
divStyle: function() {
return "height:" + this.get('height') + "px; color:"+ this.get('color') +";";
}.property('height', 'color')
}
}
这是我的模板的 sn-p:
{{#each}} <div {{bindAttr style="divStyle"}}</div> {{/each}}
但我收到以下错误:“断言失败:属性必须是数字、字符串或布尔值,而不是函数”。我正在关注这篇文章:Ember.js binding a css style in a template,但不知何故它不起作用。有什么想法吗?
【问题讨论】:
标签: javascript ember.js model