Skip to content

Commit ae16680

Browse files
committed
Merge branch 'atscott-oldnozone'
2 parents 6035526 + 604c7f9 commit ae16680

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

frameworks/keyed/angular-cf-nozone/src/app/app.component.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { NgFor } from '@angular/common';
2-
import { ChangeDetectorRef, Component, VERSION, inject } from '@angular/core';
1+
import { ApplicationRef, Component, VERSION, inject } from '@angular/core';
32

43
interface Data {
54
id: number;
@@ -12,11 +11,10 @@ const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie"
1211

1312
@Component({
1413
selector: 'app-root',
15-
imports: [NgFor],
1614
templateUrl: './app.component.html'
1715
})
1816
export class AppComponent {
19-
private cdr = inject(ChangeDetectorRef);
17+
private applicationRef = inject(ApplicationRef);
2018

2119
data: Array<Data> = [];
2220
selected?: number = undefined;
@@ -44,7 +42,7 @@ export class AppComponent {
4442
select(item: Data, event: Event) {
4543
event.preventDefault();
4644
this.selected = item.id;
47-
this.cdr.detectChanges();
45+
this.applicationRef.tick();
4846
}
4947

5048
delete(item: Data, event: Event) {
@@ -55,41 +53,41 @@ export class AppComponent {
5553
break;
5654
}
5755
}
58-
this.cdr.detectChanges();
56+
this.applicationRef.tick();
5957
}
6058

6159
run() {
6260
this.data = this.buildData();
63-
this.cdr.detectChanges();
61+
this.applicationRef.tick();
6462
}
6563

6664
add() {
6765
this.data = this.data.concat(this.buildData(1000));
68-
this.cdr.detectChanges();
66+
this.applicationRef.tick();
6967
}
7068

7169
update() {
7270
for (let i = 0; i < this.data.length; i += 10) {
7371
this.data[i].label += ' !!!';
7472
}
75-
this.cdr.detectChanges();
73+
this.applicationRef.tick();
7674
}
7775
runLots() {
7876
this.data = this.buildData(10000);
7977
this.selected = undefined;
80-
this.cdr.detectChanges();
78+
this.applicationRef.tick();
8179
}
8280
clear() {
8381
this.data = [];
8482
this.selected = undefined;
85-
this.cdr.detectChanges();
83+
this.applicationRef.tick();
8684
}
8785
swapRows() {
8886
if (this.data.length > 998) {
8987
var a = this.data[1];
9088
this.data[1] = this.data[998];
9189
this.data[998] = a;
9290
}
93-
this.cdr.detectChanges();
91+
this.applicationRef.tick();
9492
}
9593
}

0 commit comments

Comments
 (0)