ModalController, Modal and @ionic/angular docs inconsistency

I’m trying to access ModalController API definition for the new @ionic/angular package and unable to find matching docs on the API side. The new component is described here, examples are using new import:

import { ModalController } from '@ionic/angular';

But when you navigate to API to see the details, in my case I want to know what is the return type for the ModalController.create method, you will see old imports:

import { ModalController, NavParams } from 'ionic-angular';

And what is the most confusing, there is no create method in docs, so I’m not sure how I can see the return type. Previously it was Modal but it’s no longer exported in the @ionic/angular package. And I have multiple other examples of type I’m trying to find which are no longer exported (build error) and not described in the docs.

How can I find in docs what is the return type of the ModalController.create method?

I don’t know how you got to the link you presented as “navigate to API”, but if you just hover over it, you should see that it clearly has a “v3” in the URL and is therefore no longer of use to you.

I hate to come across as a shill, and if you don’t use JetBrains products, I trust that whatever you do use has a similar feature, but I do use WebStorm, and all I have to do is select an invocation of create and press control-B (Navigate -> Usages and Declarations), and it takes me to the declaration of that function, which says it returns a Promise<HTMLIonModalElement>. Repeating the exercise tells me that HTMLIonModalElement combines an @ionic/core IonModal component and an HTMLStencilElement.

2 Likes

I’m using VSCore and I did the first iteration of “go to definition”, HTMLIonModalElement confused me (as it’s not described at the ModalContorller.create docs, and I stopped, going further I did found Components.IonModal which lives in @ionic/core package, thanks for the tip! It would be nice to see this kind of information right in the ionic docs to simplify the process.

I believe that’s all open source, so maybe they’d be interested in PRs to add to them.

1 Like