mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-12 05:43:03 -05:00
26 lines
607 B
TypeScript
26 lines
607 B
TypeScript
import { NgFor, NgIf } from '@angular/common';
|
|
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
|
|
interface Person {
|
|
name: string;
|
|
}
|
|
|
|
@Component({
|
|
standalone: true,
|
|
imports: [NgFor, NgIf],
|
|
selector: 'app-root',
|
|
template: `
|
|
<ng-container *ngIf="persons.length > 0; else emptyList">
|
|
<div *ngFor="let person of persons">
|
|
{{ person.name }}
|
|
</div>
|
|
</ng-container>
|
|
<ng-template #emptyList>The list is empty !!</ng-template>
|
|
`,
|
|
styles: [],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class AppComponent {
|
|
persons: Person[] = [];
|
|
}
|