次のコードでは、 "application.js:72 TypeError:_this2.get(...)。toArrayは関数ではありません"というエラーが表示されます。私はモデルが動的に更新されるように、モデルへのサーバーの応答から来るものをプッシュしようとしています。これはコントローラで起こっています。コントローラは、テンプレート内の別のコンポーネントからアクションをインターセプトします。ここで何がうまくいかないのですか?EmberモデルaddObject関数ではありません
actions: {
sendData: function() {
this.set('showLoading', true);
let data = {
startTime: date.normalizeTimestamp(this.get('startTimestamp')),
endTime: date.normalizeTimestamp(this.get('endTimestamp')),
type: constants.ENTERPRISE.REPORTING_PAYMENT_TYPE
};
api.ajaxPost(`${api.buildV3EnterpriseUrl('reports')}`, data).then(response => {
this.set('showLoading', false);
console.log("Comes here!!!!");
console.log(this.get('model'));
this.get('model').toArray().addObject(Ember.Object.create(response));
return response.report;
}).catch(error => {
this.set('showLoading', false);
if (error.status === constants.HTTP_STATUS.GATEWAY_TIMEOUT) {
this.notify.error(this.translate('reports.report_timedout'), this.translate('reports.report_timedout_desc'));
} else {
this.send('error', error);
}
});
}
私はモデルからRSVP.hashを返します。しかし、私は確信してハッシュしています私がリクエストした時点で既に解決されています。応答に感謝します。 –
ブレークポイントを設定して解決したことを確認できますか?内容を確認していますか?非同期の関係がある場合は、別の原因かもしれません。 –