Angular add class dynamically code example
Example 1: Angular add class dynamically
<button
*ngFor="let button of buttons"
class="general"
(click)="ChangeScreen(button.label)"
[class.selected]="CurrentPage == button.label">
{{ button.label }}
</button>
Example 2: Angular add class dynamically
buttons: Array<{label: string}> = [
{
label: 'Global'
},
{
label: 'Maintenance'
},
{
label: 'Settings'
},
{
label: 'Profile'
},
{
label: 'Transactions'
}
]