Angular Material 17 No provider for DateAdapter in Standalone Component

Discussão em 'Angular' iniciado por miholzi, Abril 24, 2025.

  1. miholzi

    miholzi Guest

    I have a nx project with angular 17 app and try to use a the angular material date picker with material 17.0.4. But I get the


    NullInjectorError: No provider for DateAdapter!
    ​

    Error. The components are standalone components and so there is no app.module file.

    The component

    @Component({
    selector: 'my-component',
    standalone: true,
    imports: [
    MatFormFieldModule,
    MatInputModule,
    MatDatepickerModule,
    FormsModule,
    MatIconModule,
    MatButtonModule,
    MatNativeDateModule,
    NgIf
    ],
    providers: [MatNativeDateModule],
    templateUrl: './edit-booking.component.html',
    styleUrl: './edit-booking.component.css',
    })
    export class EditBookingComponent implements OnInit {}


    I also tried to import the providers in the app.config.ts

    export const appConfig: ApplicationConfig = {
    providers: [
    provideRouter(appRoutes),
    provideAnimations(),
    provideHttpClient(withInterceptors([authInterceptor])),
    {provide: LOCALE_ID, useValue: 'de-AT'},
    importProvidersFrom(MatNativeDateModule)

    ],
    };


    but then I get this error:


    Cannot read properties of undefined (reading 'liveCollection')
    ​

    Thanks a lot!

    Continue reading...

Compartilhe esta Página