/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
modules/benchmarks/src/tree/ng2_switch/tree.ts
41 строка
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 {emptyTree, TreeNode} from '../util'; @Component({ selector: 'tree', template: `<ng-container [ngSwitch]="data.depth % 2"> <span *ngSwitchCase="0" style="background-color: grey"> {{ data.value }} </span> <span *ngSwitchDefault> {{ data.value }} </span> <tree *ngIf="data.right != null" [data]="data.right"></tree ><tree *ngIf="data.left != null" [data]="data.left"></tree ></ng-container>`, standalone: false, changeDetection: ChangeDetectionStrategy.Eager, }) export class TreeComponent { @Input() data: TreeNode = emptyTree; } @NgModule({ imports: [BrowserModule], bootstrap: [TreeComponent], declarations: [TreeComponent], providers: [provideZoneChangeDetection()], }) export class AppModule {}