I am using tree component of angular material for my project.Here is stackblitz link,Here i need to achieve two things:
1)The text color of the child element has to change on mouse hover.
2)On clicking/selecting the child element the background color has to be changed,The background color as to be constant until i select the next child element something like list with selection.
Something like this
i have created Stackblitz demo
this code work as per your requirement
i have added some in
tree-loadmore-example.html
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding
(click)="activeNode = node" [ngClass]="{ 'background-highlight': activeNode === node }">
<button mat-icon-button></button> <span class="txtColor">{{node.item}}</span>
</mat-tree-node>
and in .ts added
activeNode:any;
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