0

所以,这是我的简单 GET 请求:

async getInspectionForm(): Promise<Observable<InspectionSummaryFormField[]>> {
let params = new HttpParams();
params = params.append('InspectionType', this.inspection.InspectionType);
params = params.append('includeInactive', 'false');

const httpComponents = await this.httpService.composeRequest('/InspectionFormCriteria', params);

return this.http.get<InspectionSummaryFormField[]>(httpComponents.fullUrl, httpComponents.httpOptions); }

这是我使用结果的地方:

this.inspectionFormCritera.subscribe(formCriteria => {

  this.inspectionStorageService.inspectionFormCriteria = formCriteria;

  for(const f of formCriteria) {
    this.inspectionSummaryForm.addControl(f.FormInputName, new FormControl('', Validators.required));

    this.saveValuesOnFormChange(f.FormInputName);

    if(f.EndpointName) {
      this.dropdownFieldIterator++;
    }

    if(f.RadioSelections) {
      this.radioSelections.push(f.RadioSelections.split('-', 5)); // Because radio button selections are defined in the database like so: option1-option2-option3.
      this.inspectionStorageService.formSelections.radioSelections = this.radioSelections;
    }
  }

  this.prepareDropdownFields(formCriteria);
}, error => {
  this.newInspectionsService.inspectionDownloadTimeoutError(error);
});

但是,在我当前的 RxJS 7.5 版本中,不推荐使用上述订阅方法......所以我使用将错误处理程序移动到error: () => {}订阅调用内的通知函数的首选语法。但是,我的 formCriteria 对象不再从具有类型 InspectionSummaryFormField[] 的可观察对象中解包,而是使用“任何”类型。

这只是一个测试版问题还是我在这里遗漏了一些重要的东西?

4

0 回答 0