/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
modules/benchmarks/src/largetable/ng2_switch/table.ts
51 строка
1 KB
Matthieu Riegler
feat(core): Set default Component changeDetection strategy to OnPush
25 мар 2026, 02:25
25 мар 2026, 02:25
eae8f7e
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { ChangeDetectionStrategy, Component, Input, NgModule, provideZoneChangeDetection, } from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; import {emptyTable, TableCell} from '../util'; @Component({ selector: 'largetable', template: `<table> <tbody> <tr *ngFor="let row of data; trackBy: trackByIndex"> <ng-template ngFor [ngForOf]="row" [ngForTrackBy]="trackByIndex" let-cell ><ng-container [ngSwitch]="cell.row % 2"> <td *ngSwitchCase="0" style="background-color: grey">{{ cell.value }}</td> <td *ngSwitchDefault>{{ cell.value }}</td> </ng-container></ng-template > </tr> </tbody> </table>`, standalone: false, changeDetection: ChangeDetectionStrategy.Eager, }) export class TableComponent { @Input() data: TableCell[][] = emptyTable; trackByIndex(index: number, item: any) { return index; } } @NgModule({ imports: [BrowserModule], bootstrap: [TableComponent], providers: [provideZoneChangeDetection()], declarations: [TableComponent], }) export class AppModule {}