データベースからcsvファイルにデータをフェッチする必要があります。私はすべてのデータを取得できましたが、オブジェクト形式のデータを取得できませんでした.CSSファイルに[オブジェクトオブジェクト]として表示されます。データベースからデータをフェッチし、Angular2を使用してCSVファイルにエクスポートする方法
TSファイル:
getData() {
let source = this.resultList;
let destination = [];
for (let i = 0; i < source.length; i++) {
let entry = new Entry();
entry.id = source[i]['id'];
entry.participantId = source[i]['participantId'];
entry.completedOn = moment(source[i]['completedOn']).format('DD/MM/YYYY');
if (typeof source[i]['satisfaction'] == 'string') {
entry['satisfaction'] = source[i]['satisfaction']
} else {
for (var property in source[i]['satisfaction']) {
if (source[i]['satisfaction'].hasOwnProperty(property)) {
entry[property] = source[i]['satisfaction'][property]
}
}
}
destination.push(entry);
}
return destination;
}
}
私はそれが代わりに項目を表示する[オブジェクトのオブジェクト]と表示される、csvファイルに "prodandService" に存在するオブジェクトをフェッチすることができません。
JSONデータ:
{ "満足":{ "prodandService":[{ "インデックス": "Orbiz"}、{ "インデックス": "qwerq"}、{ "インデックス":」 {"index": "test"}、{"index": "TestWD"}、{"index": "IOS app"}、{"index": " {"インデックス": "口紅"}、{"インデックス": "ウェブサイト"}、{"インデックス": "App IOS"}、{"索引" 「シャンプーバニラ」}、{「インデックス」:「シャンプーストロベリー」}、「インデックス」:「車」、「口紅」、「価格」、「中」、「顧客」、「はい」、 「電話」、「電話ビスト」、「3」、「重要度」:「品質」、「頻度」、「四半期」、「満足度」:「3」、 }、 "completedOn": "2017-08-28T09:39:54.676Z"、 "id":10、 "participantId":217}
助けてください。
はまた、それ 'を持つオブジェクトにするために、あなたの要求から、あなたのオブジェクトを解析することを忘れないでください.json() 'メソッド。 –