I use standalone components in Angular 17. When I used module architecture, I didn't have this problem. I added it to import in AppModule and it works good.
imports: [
TranslateModule.forRoot(loader)
],
But if I add TranslateModule.forRoot(loader) in standalone components
@Component({
selector: 'app-main-work-space',
standalone: true,
imports: [
// @ts-ignore
TranslateModule.forRoot(loader)
],
templateUrl: './main-work-space.component.html',
styleUrl: './main-work-space.component.scss'
})
In result I have this mistake.
✘ [ERROR] TS-992012: 'imports' contains a ModuleWithProviders value, likely the result of a 'Module.forRoot()'-style call. These calls are not used to configure components and are not valid in standalone component imports - consider importing them in the application bootstrap instead.
I try add @ts-ignore but it doesn't help.
How can I fix it?
I think you missed the
importProvidersFromwrapper fortranslation module, please find below working example along with extra sample code, to help you resolve your problem!stackblitz
Stackblitz for reference not by me