Reputation: 1966
I am trying to set custom timezone via useFactory
that causing an error that timeZone.replace is not a function. But with useValue
it is working fine.
@Injectable({ providedIn: 'root' })
class Foo {
bar() {
return new Promise((resolve) => {
setTimeout(() => {
resolve('-0400');
}, 1000);
});
}
}
providers: [
{
provide: DATE_PIPE_DEFAULT_TIMEZONE,
deps: [Foo],
// useValue: '-0400',
useFactory: async (foo: Foo) => {
return foo.bar();
},
},
],
See the app.module.ts
Playground: angular default timezone stackblitz
Upvotes: 0
Views: 883