setValue动态到aggular7中的对象
我有这个代码,我想重构以更好的解决方案:
async onServerRequestForDraft(res: { value: {}; tabType: ETabType; }) {
res.value = this.uiForm.value;
res.value = this.data;
res.value['brokerage'] = this.uiForm.value.brokerage != null ? this.uiForm.value.brokerage : { id: 0, name: null };
res.value['org'] = this.uiForm.value.org;
res.value['selectedPhone'] = this.uiForm.value.selectedPhone || '';
res.value['customerName'] = this.uiForm.value.customerName || '';
}
我无法使用foreach,因为RES不是数组。也许是另一个解决方案?
I have this code which I want to refactor to better solution:
async onServerRequestForDraft(res: { value: {}; tabType: ETabType; }) {
res.value = this.uiForm.value;
res.value = this.data;
res.value['brokerage'] = this.uiForm.value.brokerage != null ? this.uiForm.value.brokerage : { id: 0, name: null };
res.value['org'] = this.uiForm.value.org;
res.value['selectedPhone'] = this.uiForm.value.selectedPhone || '';
res.value['customerName'] = this.uiForm.value.customerName || '';
}
I can't use forEach because res is not an array. maybe another solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管可以使用它,但您不需要工作。
如果您只想使用循环,则可以这样做:
You don't need forEach for it to work though you can use it.
If you want to use loop only, you can do it this way:
您可以在这样的对象上使用foreach:
u can use forEach on Object like this :