Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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 合并贴图角度_Angular_Typescript_Ionic2_Mergemap - Fatal编程技术网

Angular 合并贴图角度

Angular 合并贴图角度,angular,typescript,ionic2,mergemap,Angular,Typescript,Ionic2,Mergemap,你能告诉我我做错了什么吗 this.scheduleService.GetZones(environment.systemId) .烟斗( 合并地图((区域:区域)=>{ 返回此.dashboardService.GetLatestMeasurementValue(environment.systemId,zone.sensorId) }) .订阅(mois=>{ 此.CurrentWatery=MOI; }) ); } 我遇到了以下错误:类型“OperatorFunction”上不存在属性“

你能告诉我我做错了什么吗

this.scheduleService.GetZones(environment.systemId)
.烟斗(
合并地图((区域:区域)=>{
返回此.dashboardService.GetLatestMeasurementValue(environment.systemId,zone.sensorId)
})
.订阅(mois=>{
此.CurrentWatery=MOI;
})
);
}

我遇到了以下错误:类型“OperatorFunction”上不存在属性“subscribe”

您无法订阅运算符。您需要按如下方式订阅

this.scheduleService.GetZones(environment.systemId)
.烟斗(
合并地图((区域:区域)=>{
返回此.dashboardService.GetLatestMeasurementValue(environment.systemId,zone.sensorId);
})
)
.订阅(mois=>{
此.CurrentWatery=MOI;
})

您不能订阅运营商。您需要按如下方式订阅

this.scheduleService.GetZones(environment.systemId)
.烟斗(
合并地图((区域:区域)=>{
返回此.dashboardService.GetLatestMeasurementValue(environment.systemId,zone.sensorId);
})
)
.订阅(mois=>{
此.CurrentWatery=MOI;
})

我看到我们正在通过此方法名称将区域值映射到最新度量值
GetLatestMeasurementValue
。 如果您总是对最新的值感兴趣,则是更好的运算符

this.scheduleService.GetZones(environment.systemId)
    .pipe(
       switchMap((zone: Zone) => {
          return this.dashboardService.GetLatestMeasurementValue(environment.systemId, zone.sensorId);
       })
     )
    .subscribe(mois => {
      this.currentMoisture = mois;
    })
如果是单个时间事件,simple
map
也会执行以下操作:

this.scheduleService.GetZones(environment.systemId)
    .pipe(
       map((zone: Zone) => {
          return this.dashboardService.GetLatestMeasurementValue(environment.systemId, zone.sensorId);
       })
     )
    .subscribe(mois => {
      this.currentMoisture = mois;
    })

我看到我们正在通过此方法名称将区域值映射到最新的度量值
GetLatestMeasurementValue
。 如果您总是对最新的值感兴趣,则是更好的运算符

this.scheduleService.GetZones(environment.systemId)
    .pipe(
       switchMap((zone: Zone) => {
          return this.dashboardService.GetLatestMeasurementValue(environment.systemId, zone.sensorId);
       })
     )
    .subscribe(mois => {
      this.currentMoisture = mois;
    })
如果是单个时间事件,simple
map
也会执行以下操作:

this.scheduleService.GetZones(environment.systemId)
    .pipe(
       map((zone: Zone) => {
          return this.dashboardService.GetLatestMeasurementValue(environment.systemId, zone.sensorId);
       })
     )
    .subscribe(mois => {
      this.currentMoisture = mois;
    })

mergeMap
将使您的
this.scheduleService.GetZones
保持活动状态。如果您的服务按照我想的方式工作,我会考虑<代码>开关图< /C> >,这将确保<代码>。如果你的服务按照我想的方式工作,我会考虑<代码>开关图< /C>,这将确保<代码>。