简体   繁体   中英

Change displayed language of Timeagopipe" in ionic2 app

hi everyone im trying to change displayed language of Timeagopipe" in my page1.html :

{{myDatet | amTimeAgo}}

prints: 4 days ago

How can i change it into other language , no English ?

i tried write moment.local('he') in page1.ts constractor and nothing happens , Still prints: 4 days ago

thanks

Create pipe class

import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'myDatet'})
export class ExponentialStrengthPipe implements PipeTransform {
  transform(value: number, exponent: string): number {
    return exponent; // do something with your {amTimeAgo} value
  }
}

After that in your component add and include pipe

import { Component } from '@angular/core';

import { ExponentialStrengthPipe } from './exponential-strength.pipe';

    @Component({
      selector: 'power-booster',
      template: `
        <h2>Power Booster</h2>
        <p>Super power boost: {{amTimeAgo | myDatet}}</p>
      `,
      pipes: [ExponentialStrengthPipe]
    })
    export class PowerBoosterComponent { }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM