【发布时间】:2013-05-27 12:27:42
【问题描述】:
我有以下代码,我希望返回 [1000] 但返回 [undefined]:
this.get('details').getEach('gross_total')
但是
this.get('details')[0].get('gross_total')
确实有效并返回 1000。
我现在正在使用 rc3。 rc1 中的相同代码运行良好。
我的持久层取自话语。相关型号如下。发票有_很多细节
App.Invoice = App.Model.extend App.Commentable,
invoice_number: App.Attr('string')
description: App.Attr('string')
issue_date: App.Attr('date')
due_date: App.Attr('date')
contact: App.BelongsTo('App.Contact', "contacts")
details: App.HasMany('App.InvoiceDetail', "detail_ids")
payments: App.HasMany('App.Payment', "payment_ids")
invoice_status: App.Attr('string')
comments: App.HasMany('App.Comment', "comment_ids")
App.InvoiceDetail = App.Model.extend App.DestroyableChild,
detail_no: App.Attr('int')
description: App.Attr('string')
quantity: App.Attr('float')
unit_price: App.Attr('currency')
consumption_tax_rate: App.Attr('float')
vat_rate: App.Attr('float')
discount_type: App.Attr('string')
discount_value: App.Attr('currency')
product: App.BelongsTo('App.Product', 'products')
【问题讨论】:
-
假设 this.get('details') 是数据库中的记录数组,你能粘贴细节模型定义的代码吗?
-
这就是它变得棘手的地方,我并没有完全展示要展示的内容。我有一个持久层的自定义实现,主要取自话语。我已经更新了我上面的问题,但不幸的是,我认为这并不是很有帮助。
标签: ember.js