How can I dynamically assign classes in HTML based on a property in Angular 2 without using jQuery or Bootstrap? I am trying to open a dropdown list.
Here is what I have:
<li
class="dropdown mega-menu mega-menu-wide"
//stuck at adding class of open if propertyval is admin
>
<a #admin class="dropdown-toggle" (click)="toggle(admin)" >Administrative</a>
</li>
In my TypeScript file, I have:
export class ... {
propertyval :null
toggle(val){
this.propertyval = null;
}
}
Now, I want to add the class "open" to the list if the value of propertyval is "admin", otherwise it should remain null.
How can I achieve this?