Ionic4 - Segment

I am trying out ionic4 beta, recently i just found ion-segment (ionChanged) event is not passing ion-segment-button value
Anyone has already got this error and could able to resolve it ?

<ion-segment [(ngModel)]=‘currentTab’ (ionChange)=“segmentChanged($event)”>

private segmentChanged(segment: any) {
console.log('Tab changed: ’ + JSON.stringify(segment))
}

output:
Tab changed: {“isTrusted”:false}

not sure that’s your error but the first thing I see is that your method segmentChanged should be public not private as it is use from your template

1 Like

i made it as public and it is the same. As i mentioned the event is triggering but the $event what i am receiving on the function is {“isTrusted”:false}.
i appreciate your help.

second thing you could try, remove the JSON.stringify in your console.log

 console.log('Tab changed’, segment);

better?

1 Like

Hello,
It might be late, but to help others. Yes, when you output the event, it states only { isTrusted: false }. But you can still access the CustomEvent value using event.detail.value. See link bellow for more info:

Cheers
Filip

1 Like

Thank you, that’s helpful!

I was looking for this in the Ionic and Angular documentation but couldn’t find it.