Getting Started with Angular

Handling Click Events

To handle DOM events, we just need to wrap that event that we want to watch for with (). This is the event binding and we can watch for any events, even custom ones that we'll make ourselves in later lessons.

<div *ngIf="users">
    <ul class="list-group users-list">
    <li class="list-group-item"
        *ngFor="let user of users"
        (click)="selectUser(user)"
        [class.active]="user === activeUser">
            {{ user.name }} ({{ user.username }})
    </li>
    </ul>
</div>