Search code examples
angulartypescriptionic2mergemap

Merge map Angular


Can you tell me what am I doing wrong ?

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

I get this error: Property 'subscribe' does not exist on type 'OperatorFunction'


Solution

  • You cannot subscribe to an operator. You need to subscribe as follows.

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