triniwiz / nativescript-accordion

Apache License 2.0
38 stars 14 forks source link

how to get parent index when click the child #58

Open RajkumarRepo opened 5 years ago

RajkumarRepo commented 5 years ago

I'm not able to get parent and child index individually I'm able to get id but when click the child I want to get the parent id.

RajkumarRepo commented 5 years ago

I want to get parent index when click the child.

triniwiz commented 5 years ago

There is a tap event emitted when tapping on a child it contains the parent index event.index and the child index event.childIndex

RajkumarRepo commented 5 years ago

Thank you yeah it was worked perfectly.

Design File

<Accordion class="list-group" [items]="groups"
            (itemContentTap)="onItemContentTap($event)">

Ts File

onItemContentTap(event) {
        const data = event.data;
        console.log(event.index);
        console.log(event.childIndex); // Index is always one more than what user taps
        console.log(data); 
}
RajkumarRepo commented 5 years ago

Child Index returns wrong Value