Created
February 13, 2025 10:28
-
-
Save Armenvardanyan95/9b3153c615827437fe7dd222482cba32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| template: ` | |
| <h2>User List:</h2> | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Username</th> | |
| <th>Email</th> | |
| <th>Last Login</th> | |
| <th>Role</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| @for (user of filteredUsers(); track user.id) { | |
| <tr> | |
| <td>{{ user.username }}</td> | |
| <td>{{ user.email }}</td> | |
| <td>{{ user.lastLogin.toLocaleString() }}</td> | |
| <td>{{ user.role }}</td> | |
| </tr> | |
| } @empty { | |
| <tr> | |
| <td colspan="4"> | |
| No users match the filter. | |
| </td> | |
| </tr> | |
| } | |
| </tbody> | |
| </table> | |
| `, | |
| standalone: true, | |
| }) | |
| export class UserListComponent { | |
| users = input.required<User[]>(); | |
| showOnlyActive = input(false); | |
| filteredUsers = computed(() => { | |
| const onlyActive = this.showOnlyActive(); | |
| const usersList = this.users(); | |
| if (!onlyActive) { | |
| return usersList; | |
| } | |
| return usersList.filter(user => user.isActive); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment