</div>
<div class="card-body">
<ul class="list-unstyled">
- <li class="input-group mb-1" *ngFor="let message of messages">
- <span class="input-group-text">{{message.user}}</span>
- <span class="form-control">{{message.text}}</span>
- </li>
+ @for (message of messages; track message) {
+ <li class="input-group mb-1">
+ <span class="input-group-text">{{message.user}}</span>
+ <span class="form-control">{{message.text}}</span>
+ </li>
+ }
</ul>
</div>
</div>
import { UserService } from '../user/user.service';
import { Chatroom } from './chatroom';
import { Message } from './message';
-import { NgFor } from '@angular/common';
+
@Component({
selector: 'app-chatroom',
templateUrl: './chatroom.component.html',
styleUrls: ['./chatroom.component.less'],
- imports: [NgFor],
+ imports: [],
})
export class ChatroomComponent implements OnInit, OnDestroy {
<h1 class="h5">Please Choose a Chat-Room</h1>
</div>
<div class="card-body d-grid gap-1">
- <button *ngFor="let chatroom of chatrooms" routerLink="/chatroom/{{chatroom.shard ? chatroom.shard : '_'}}/{{chatroom.id}}" type="button" class="btn btn-outline-primary">{{chatroom.name}}</button>
+ @for (chatroom of chatrooms; track chatroom) {
+ <button routerLink="/chatroom/{{chatroom.shard ? chatroom.shard : '_'}}/{{chatroom.id}}" type="button" class="btn btn-outline-primary">{{chatroom.name}}</button>
+ }
</div>
</div>
import { UserService } from "../user/user.service";
import { ChatroomService } from "../chatroom/chatroom.service";
import { RouterLink } from '@angular/router';
-import { NgFor } from '@angular/common';
+
@Component({
selector: 'app-chatrooms',
templateUrl: './chatrooms.component.html',
styleUrls: ['./chatrooms.component.less'],
- imports: [NgFor, RouterLink],
+ imports: [RouterLink],
})
export class ChatroomsComponent implements OnInit
{
<button type="submit" class="btn btn-primary" (click)="updateName()" [disabled]="usernameForm.invalid">Pick</button>
</div>
</div>
- <div *ngIf="usernameForm.invalid && (usernameForm.dirty || usernameForm.touched)">
- <div *ngIf="usernameForm.errors?.['required']">Name is required.</div>
- <div *ngIf="usernameForm.hasError('whitespace')">The username must not be empty</div>
- </div>
+ @if (usernameForm.invalid && (usernameForm.dirty || usernameForm.touched)) {
+ <div>
+ @if (usernameForm.errors?.['required']) {
+ <div>Name is required.</div>
+ }
+ @if (usernameForm.hasError('whitespace')) {
+ <div>The username must not be empty</div>
+ }
+ </div>
+ }
</div>
<div class="card-footer">
<span class="float-start">Value: {{ usernameForm.value }}</span>
} from '@angular/forms';
import { Router } from "@angular/router";
import { UserService } from "./user.service";
-import { NgIf } from '@angular/common';
+
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.less'],
- imports: [ReactiveFormsModule, NgIf],
+ imports: [ReactiveFormsModule],
})
export class UserComponent {