首页 > 解决方案 > 将响应对象的值分配给模型对象

问题描述

我在 Angular 中实现了一个服务方法,它调用 asp.net webapi,它通过响应对象返回一个整数数组。我需要将这些值作为模型对象的一部分捕获,并将其传递给另一个名为 getDocumentUploadDetailsByIds 的端点调用。我最初尝试将值直接传递到我的端点,但在到达断点时它为空。所以我决定将数组作为数组对象的一部分传递。如何将值分配给模型 ids 数组。有人可以告诉我如何实现这一目标。

export interface IDocumentIds {
  ids: number[];
}


   documentIds: IDocumentIds;

    this.documentUploadService.createDocumentUpload(this.documents)
                .then((result) => {
                    if (result) {
                        //this.documentIds.ids = result;
                        this.getDocumentUploadDetailsByIds(result);
                        this.setGridOptions();
                        this.setColumns();
                        this.notify.success('Documents uploaded Successfully');
                    }
                }).catch(err => {
                    this.notify.error('An Error Has Occured While uploading the documents');
                });

标签: angular

解决方案


推荐阅读