All good, however any subsequent calls to modalController.create(...); will not run the setup() function in my modal component.
I was under the impression that modalController.dismiss(); would unmount the component, but it seems it does not.
Funnily enough, if I use the inline modal, everything works as expected. The modal is unmounted when dismissed, so setup() is always called.
To keep the inline modal mounted, there is an extra option to pass: keepContentsMounted.
When using modalController instead, it looks like it is never unmounted, so setup() is called only once.
I am not sure why there is this inconsistency, I would expect to pass the keepContentsMounted boolean to modalController.create() if I wanted to keep my modal component around, like we do for the inline modal.
Sorry, I’m not clear without seeing your code. When I use const modal = modalController.create(...); within a button handler, for example, then I am seeing the setup function run in the modal component every time. How are you calling create, and where are you storing the returned HTMLIonModalElement? Maybe it is persisting in your parent component?
In my setup script component, the “top level ts code” becomes the setup script, and it is being executed every time I create and present the modal.