Use translate service in error block

Hello,

I want to use the translate service in an error block like this…

this.backendApi.readData(.subscribe(
       success => xxx,
       error => {
         this.translateService.get(error)['value'];
       },
       ()
     );

But got error for this.translateService

 Cannot read property 'get' of undefined

So how can I use the translateService here?

Maybe, not sure, would you like to try:

 var self = this; 
 
  this.backendApi.readData().subscribe(
   success => xxx,
   error => {
     self.translateService.get(error)['value'];
   },
   ()
 );

p.s.: also doesn’t .get get a promise back? if so, you could try this.translateService.instant('key') … just a side note