I'm developing an angular 7 application with lazy loaded modules. I'm using angular material components as well. I would like to localize and support multiple locales in datepicker component.
I would like to change it globally for the whole application when application language changes. It may be done via DateAdapter.setLocale method. However the problem is that if I change it on my root module then it does not change in lazy loaded modules.
Yes, lazy loaded modules have their injector and receive their DateAdapter, where locale is not set to the correct one.
How to achieve that DateAdapter is singleton in the whole app? For other modules there is a forChild() vs forRoot() API, but not for datepicker module.
providedIn: 'root'
in your singleton service then, whenever you need to use it, use@Inject(DateAdapter)
so that angular is aware that it needs to inject the service instance. – briosheje