ngx-timeago icon indicating copy to clipboard operation
ngx-timeago copied to clipboard

Angular 17 support

Open benshabatnoam opened this issue 5 months ago • 2 comments

Hi there, Will you guys be able to update this package to support Angular 17? Thank!

benshabatnoam avatar Jan 30 '24 17:01 benshabatnoam

I'd also be interested in an update.

Trying to implement ngx-timeago with the latest Angular version - and it kinda works.

Even though I'm trying to assign the localized strings in the constructor of my component to the service and call the changes.next() method, the text stays in english.

In the debugger I can see the string values in german being assigned to the service - but it doesn't do anything.

Since Angular 17 has a little different architecture, my approach was to put TimeagoModule.forRoot({}) into importProvidersFrom in app.config.ts. Also I added TimeagoIntl to the providers list there.

Some updated docs might be nice, too!

Any hints are welcome!

bastibense avatar Feb 16 '24 11:02 bastibense

Hi! I've encountered the same problem, using standalone components also. The solution that worked for me:

In main.ts:

...
providers: [
      importProvidersFrom(
        BrowserModule,
        AppRoutingModule,
        TimeagoModule.forRoot({
          intl: {
            provide: TimeagoIntl,
          },
          formatter: {
            provide: TimeagoFormatter,
            useClass: TimeagoCustomFormatter,
          },
        })
      ),
      AuthService,
      ScreenService,
      AppInfoService,
    ]

In app.component.ts:

import { strings as roIntlStrings } from 'ngx-timeago/language-strings/ro';
constructor(
    ...
    private timeagoIntl: TimeagoIntl
  ) {
    this.timeagoIntl.strings = roIntlStrings;
    this.timeagoIntl.changes.next();
  }

CosovanuA avatar Mar 16 '24 17:03 CosovanuA