Since p-tree from PrimeNG does not have way of using rowIndex.
How do I display/get the Index of nodes each node using ng-template.
Is there any workaroud?
Within the ng-template, you can call the indexOf() method on your collection and pass the current item as the argument. This will either return the index of the first instance of that item or -1 if that item isn't found. You can display the result of that call within curly braces in the HTML.
<p-tree [value]="items">
<ng-template let-item pTemplate="default">
<span>{{ items.indexOf(item) }}</span>
</ng-template>
</p-tree>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With