Hi! I’m currently developing a PWA with Ionic v4 and Angular 6. I’m trying to reinforce typescript usage over my team, and while typing everything it struck me with a question: Which type does ionchange
event belong? I couldn’t find it over the docs.
Also, I don’t know if it is a high impact question, but does the ionchange event type change over the different elements, or are they all the same?
Thanks!
1 Like
Wcjord
January 1, 2019, 4:16pm
3
In Ionic v3, it’s TextInput
which you can use like
import { TextInput } from 'ionic-angular';
onMessageChange(change: TextInput): any {
...
}
Don’t think so, I think there isn’t a type TextInput
in Ionic v4
p.s.: for references, no such results https://github.com/ionic-team/ionic/search?q=TextInput&unscoped_q=TextInput
Wcjord
January 1, 2019, 4:57pm
5
Hm ok, I clarified the version. I’m using TextInput now in an Ionic v3 project just like above so I know it works there.
OP is building a PWA with Ionic v4 and looking for a v4 solution. ‘TextInput’ doesn’t exist in v4.
I use an ion-select and receive an object of type “CustomEvent” for (ionChange).
1 Like
mitch42
October 30, 2020, 10:08am
8
For anyone looking for the answer for Ionic 5, I dug up the type in node/modules/@ionic /core/dist/components.d.ts
"onIonChange"?: (event: CustomEvent<SegmentChangeEventDetail>) => void;
Had to import it from ionic/core :
import { SegmentChangeEventDetail } from '@ionic/core/dist/types/interface';
For that, I had to to add ‘@ionic /core’ to my npm dependencies. So I don’t really know if it’s the right way to do do it…
And yes, it seems the type changes for every Component !
Hope this helps ! Cheers !
3 Likes