#DatePicker in a Dialog

8 messages · Page 1 of 1 (latest)

rain ferry
#

Hello everyone. I am using Angular 17 and Standalone Components.
I have main-page.components.ts that is opening a dialog with a component like this
this.dialog.open(OtherComponent);

Inside OtherComponent I have a form with a DatePicker. When I click on the datepicker I get this error

  NullInjectorError: No provider for DateAdapter!```

I have `MatNativeDateModule` and `MatDatepickerModule` already imported in the OtherComponent

Do you guys have any clue?
pseudo hinge
#
    MatDatepickerModule,  
  ]```
Add it to the providers, error tells you exactly what's missing.
steel cairn
#

Well, that's not what's missing. What's missing is

providers: [importProvidersFrom(MatNativeDateModule)]

(in the application config).

pseudo hinge
rain ferry
steel cairn
#

Maybe you have the adapter provided elsewhere.

rain ferry
# steel cairn Maybe you have the adapter provided elsewhere.

Yeah that's the thing, no other places have the adapter, that's why I didn't even think about the provider in the firstplace. Because before the component was rendered through the HTML and it working fine, but now I want to make it through a Dialog popup

#

Removed the MatNativeDateModule from the imports of the various components and that seems to work fine. Thanks anyway