mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-12 22:03:03 -05:00
feat(doc): move ngfor enhanvement
This commit is contained in:
25
apps/angular/ngfor-enhancement/src/app/app.component.ts
Normal file
25
apps/angular/ngfor-enhancement/src/app/app.component.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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[] = [];
|
||||
}
|
||||
Reference in New Issue
Block a user