Handle Segmented bar selectedindexchange event in view model class


#1

Hi,
I want to handle segmented bar selected index change event my view model class. I am using binding context to trigger the event. I use typescript template not angular.

main.xml
<SegmentedBar id="segment" class="segmented-bar medium-margin" selectedIndex="{{ sbSelectedIndex }}"  selectedIndexChange="{{ sbIndexChange }}">
viewmodel.xml
export class MyViewModel extends Observable{
constructor() {
        super();
}

public sbIndexChange(){
// code goes here
}
}

thanks.


#2

Property change events can’t be used in XML - it’s a limitation to NativeScript Core. You can use selectedIndexChanged event instead.