Skip to content

Commit b94adb9

Browse files
refactor: use built-in control flow in js-web-frameworks benchmark (angular#55988)
Migrate the js-web-frameworks benchmark to use the built-in control flow instead of the ngFor loop. PR Close angular#55988
1 parent 6aeea69 commit b94adb9

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

  • modules/benchmarks/src/js-web-frameworks/ng2

modules/benchmarks/src/js-web-frameworks/ng2/rows.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ export interface RowData {
1919
template: `
2020
<table class="table table-hover table-striped test-data">
2121
<tbody>
22-
<tr [class.danger]="item.id === selected" *ngFor="let item of data; trackBy: itemById">
23-
<td class="col-md-1">{{ item.id }}</td>
24-
<td class="col-md-4">
25-
<a href="#" (click)="select(item.id); $event.preventDefault()">{{ item.label }}</a>
26-
</td>
27-
<td class="col-md-1">
28-
<a href="#" (click)="delete(item.id); $event.preventDefault()">
29-
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
30-
</a>
31-
</td>
32-
<td class="col-md-6"></td>
33-
</tr>
22+
@for(item of data; track item.id) {
23+
<tr [class.danger]="item.id === selected">
24+
<td class="col-md-1">{{ item.id }}</td>
25+
<td class="col-md-4">
26+
<a href="#" (click)="select(item.id); $event.preventDefault()">{{ item.label }}</a>
27+
</td>
28+
<td class="col-md-1">
29+
<a href="#" (click)="delete(item.id); $event.preventDefault()">
30+
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
31+
</a>
32+
</td>
33+
<td class="col-md-6"></td>
34+
</tr>
35+
}
3436
</tbody>
3537
</table>
3638
`,
@@ -41,10 +43,6 @@ export class JsWebFrameworksComponent {
4143

4244
constructor(private _appRef: ApplicationRef) {}
4345

44-
itemById(index: number, item: RowData) {
45-
return item.id;
46-
}
47-
4846
select(itemId: number) {
4947
this.selected = itemId;
5048
this._appRef.tick();

0 commit comments

Comments
 (0)