是否可以从 Promise 数组中获取特定参数?
我有型号:
App.Item = DS.Model.extend({
length: DS.attr('string'),
time: DS.attr('string'),
number: DS.attr('string')
})
在 this.store.find('item')
之后我得到 DS.PromiseArray。为了图表的目的,我需要类似的东西
[[时间1,数字1],[时间2,数字2],[时间3,数字3] ....]
我已尝试 .getEach('time')
和 .getEach('number')
获取属性的单个列表,如何将它们连接在一起?
谢谢
最佳答案
尝试:
this.store.find('item').then(function(items) {
return items.map(function(item) {
return [item.get('time'), item.get('number')];
})
});
关于javascript - 如何从 DS.Promisearray 获取特定属性数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19039279/