Ejemplo: onclick agregar clase activa en angular
You can do something like:
<ul class="sub_modules">
<li (click)="activateClass(subModule)"
*ngFor="let subModule of subModules"
[ngClass]="{'active': subModule.active}">
<a>{{ subModule.name }}</a>
</li>
</ul>
On The component
activateClass(subModule){
subModule.active = !subModule.active;
}
On the Ng class the first property is the class you wanna add and the second is the condition;
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)