eakoriakin / ionic-selectable

Ionic Selectable is an Ionic versatile and highly customizable component that serves as a replacement to Ionic Select, and allows to search items, including async search, create items, customize the layout with templates and much more. It provides an intuitive API and is easy to set up and use.
MIT License
550 stars 123 forks source link

ModalController NullInjectorError using Ionic 7 Standalone & v5.0.3 #444

Closed loneoakdev closed 8 months ago

loneoakdev commented 8 months ago

I'm having a problem getting standalone working. I'm using Angular v17.0.7, Ionic v7.6.1, and Ionic Selectable v5.0.3

I am not importing anything in my main.ts file. I'm importing IonicSelectableComponent in my standalone component. As soon as I access that component, I get the following error in the console:

NullInjectorError: R3InjectorError(Standalone[_AccountProfilePage])[ModalController -> ModalController -> ModalController -> ModalController]: NullInjectorError: No provider for ModalController!

I know Ionic Selectable uses the ModalController from Ionic to display the list of options. I tried adding ModalController to the providers array for the component which didn't work. I also tried importing IonicSelectableModalComponent in the imports array which also didn't work.

Any suggestions how to get around this error? Thanks.

loneoakdev commented 8 months ago

I was importing ModalController from @ionic/angular/standalone like the rest of the Ionic objects in a standalone project. If you import it from @ionic/angular instead, it works fine. Hope this helps someone else though.