Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 平面图问题从角度4转换为角度9_Angular_Rxjs - Fatal编程技术网

Angular 平面图问题从角度4转换为角度9

Angular 平面图问题从角度4转换为角度9,angular,rxjs,Angular,Rxjs,我在Angular 4中有以下代码(全部正常) public resolve():可观察{ const permissionResponse=this.flowsService.getPermissions(); 返回permissionResponse.flatMap((权限)=>{ const result=new GridViewDtcConfig(); result.title=‘出站流量’; result.hideCompletedColumn=false; result.permis

我在Angular 4中有以下代码(全部正常)

public resolve():可观察{
const permissionResponse=this.flowsService.getPermissions();
返回permissionResponse.flatMap((权限)=>{
const result=new GridViewDtcConfig();
result.title=‘出站流量’;
result.hideCompletedColumn=false;
result.permissionResponse=权限;
result.successFlag=true;
可观察的回报(结果);
});
}
到目前为止,我已经:

import { Observable, of } from 'rxjs';
import { flatMap } from 'rxjs/operators';
...... 
public resolve(): Observable<GridViewDtcConfig> {

    const permissionResponse = this.flowsService.getPermissions();

    return permissionResponse.pipe(flatMap((permissions) => {
      const result = new GridViewDtcConfig();

      result.title = 'Outbound Flows';
      result.hideCompletedColumn = false;
      result.permissionResponse = permissions;
      result.successFlag = true;

      return of(result);
    }));
  }
import{Observable,of}来自'rxjs';
从“rxjs/operators”导入{flatMap};
...... 
公共解析():可观察{
const permissionResponse=this.flowsService.getPermissions();
返回permissionResponse.pipe(flatMap((权限)=>{
const result=new GridViewDtcConfig();
result.title=‘出站流量’;
result.hideCompletedColumn=false;
result.permissionResponse=权限;
result.successFlag=true;
返回(结果);
}));
}
但它似乎不喜欢我使用平面地图。有谁能建议我应该如何重构原始代码以符合V9吗

我收到以下错误:

常量结果:GridViewDtcConfig

(TS)“可观察”类型不可分配给类型 “可观察的”。类型“{}”缺少以下内容 “GridViewDtcConfig”类型的属性:标题,hideCompletedColumn, ObservereData、permissionResponse、successFlag


你不需要
,我只需要使用
地图

试试这个:

import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; // use map instead and you won't need of
...... 
public resolve(): Observable<GridViewDtcConfig> {

    const permissionResponse = this.flowsService.getPermissions();

    return permissionResponse.pipe(map((permissions) => {
      const result = new GridViewDtcConfig();

      result.title = 'Outbound Flows';
      result.hideCompletedColumn = false;
      result.permissionResponse = permissions;
      result.successFlag = true;

      return result;
    }));
  }
从'rxjs'导入{Observable};
从“rxjs/operators”导入{map};//使用地图代替,您将不需要
...... 
公共解析():可观察{
const permissionResponse=this.flowsService.getPermissions();
返回permissionResponse.pipe(映射((权限)=>{
const result=new GridViewDtcConfig();
result.title=‘出站流量’;
result.hideCompletedColumn=false;
result.permissionResponse=权限;
result.successFlag=true;
返回结果;
}));
}

尝试
mergeMap
而不是
flatMap
。@AliF50仍然存在同样的问题。问题是什么?有趣的是……保留flatMap,但根据您的答案更改我的报税表解决了问题。谢谢你对我的坚持。
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; // use map instead and you won't need of
...... 
public resolve(): Observable<GridViewDtcConfig> {

    const permissionResponse = this.flowsService.getPermissions();

    return permissionResponse.pipe(map((permissions) => {
      const result = new GridViewDtcConfig();

      result.title = 'Outbound Flows';
      result.hideCompletedColumn = false;
      result.permissionResponse = permissions;
      result.successFlag = true;

      return result;
    }));
  }