Search code examples
angularfrontendbackendlight

how do On/Off light in angular?


I have a list of users and I need to create badge circle(green/red) on each user in angular, for active user there is circle green light , and for inactive user there is circle red light .. thanks


Solution

  • Here is how you can generate the status dynamically:

    <li *ngFor="let user of users">
            <span class="dot" [ngClass]="{'active': (user.status==='on'), 'inactive':(user.status === 'off')}"></span>
            {{user.name}}
          </li>
    

    Here is the working example : Stackblitz Example