【发布时间】:2012-09-28 11:18:16
【问题描述】:
我想在 Coffeescript 中实现以下 Javascript 代码
App.ItemView = Ember.View.extend({
classNameBindings: ['itemId'],
itemId: function() {
console.log(this.get('content'));
return "item-%@".fmt(this.get('content.id'));
}.property('content.id'),
templateName: 'item'
});
这是我目前在 coffeescript 中的内容:
App.ItemView = Ember.View.extend(
classNameBindings: ['itemId']
itemId: ->
console.log this.get('content')
contentId = this.get('content.id')
"item-#{contentId}");
.property('content.id')
templateName: 'item'
)
我明白了:
Error: Parse error on line 11: Unexpected '.'
问题似乎与.property('content.id')
中的点有关。我不知道这如何转化为 Coffeescript。如何在 Coffeescript 中正确实现此视图?
【问题讨论】:
标签: coffeescript ember.js