Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular language translate in typescript file

public typeArray= [
       {
          id: 'MOTHER',
          name: '{{ myApp.type.MOTHER | translate }}'     
       }];

How can we write to translate while defining an array in a TypeScript file?

like image 344
s.Php developer Avatar asked Jul 01 '26 08:07

s.Php developer


1 Answers

You can use your pipes in your components or anywhere you want by importing them. Import your translate pipe to your component, then add it to constructor

constructor(private yourPipe: YourPipe) {}

or you can create a new instance from your pipe class:

public yourPipe: YourPipe = new YourPipe();

Then you can use it like this:

this.yourPipe.transform(value);

transform function will return the transformed value by the pipe.

So in your case:

   public typeArray = [
       {
         id: 'MOTHER',
         name: this.yourPipe.transform(myApp.type.MOTHER)
       }
   ];
like image 132
Efe Avatar answered Jul 05 '26 16:07

Efe