/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
modules/benchmarks/src/js-web-frameworks/ng2/rows.ts
60 строк
2 KB
Matthieu Riegler
ci: reformat files
17 дек 2025, 01:44
17 дек 2025, 01:44
6270bba
Код
Авторство
О чём код?
/** * @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 {ApplicationRef, Component} from '@angular/core'; export interface RowData { id: number; label: string; } @Component({ selector: 'js-web-frameworks', template: ` <table class="table table-hover table-striped test-data"> <tbody> @for (item of data; track item.id) { <tr [class.danger]="item.id === selected"> <td class="col-md-1">{{ item.id }}</td> <td class="col-md-4"> <a href="#" (click)="select(item.id); $event.preventDefault()">{{ item.label }}</a> </td> <td class="col-md-1"> <a href="#" (click)="delete(item.id); $event.preventDefault()"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> </a> </td> <td class="col-md-6"></td> </tr> } </tbody> </table> `, }) export class JsWebFrameworksComponent { data: Array<RowData> = []; selected: number | null = null; constructor(private _appRef: ApplicationRef) {} select(itemId: number) { this.selected = itemId; this._appRef.tick(); } delete(itemId: number) { const data = this.data; for (let i = 0, l = data.length; i < l; i++) { if (data[i].id === itemId) { data.splice(i, 1); break; } } this._appRef.tick(); } }