Apologies if this question has been addressed before, I found two similar answers here:
Question related | Close Solution
An Angular Material Sidenav component contains three components. The parent component (highlighted in red) includes tab-like buttons that load one of the three components upon clicking.
<button (click)="onTabClick(1)"><i class="fas fa-layer-plus"></i>
<button (click)="onTabClick(2)"><i class="fas fa-map-marker-edit"></i></button>
<button (click)="onTabClick(3)"><i class="fas fa-plus-square"></i></button>
The buttons switch out components using *ngIf
<app-map-features *ngIf="tabIndex === 1" [id]="'test'" ></app-map-features>
<app-map-edit-live-data *ngIf="tabIndex === 2" [id]="'test2'" ></app-map-edit-live-data>
<app-map-zoom *ngIf="tabIndex === 3" [className]="'other'"></app-map-zoom>
TypeScript:
export class containingComponent implements OnInit {
tabIndex = 1 ;
onTabClick(index) {
this.tabIndex = index;
}
A background color is applied to the Font-Awesome icon on click, working as intended.
.fas:hover {
background-color: $primary-color;
}
The objective is to change the .fas background color when a specific component is displayed, indicating which component's content is visible.
I won't delve into unsuccessful attempts, but how can I update the class to reflect the tabIndex value and make components aware of each other?