1- import { ɵdetectChanges as detectChanges , AfterViewChecked , Component , NgModule , VERSION } from '@angular/core' ;
2- import { NgForOf } from './ng_for_of ' ;
1+ import { ɵdetectChanges as detectChanges , AfterViewChecked , Component , NgModule , ChangeDetectorRef , VERSION } from '@angular/core' ;
2+ import { CommonModule } from '@angular/common ' ;
33
44interface Data {
55 id : number ;
@@ -32,7 +32,7 @@ let stopMeasure = function () {
3232 <div class="jumbotron">
3333 <div class="row">
3434 <div class="col-md-6">
35- <h1>Angular v6.1 .0 (ivy renderer)</h1>
35+ <h1>Angular v7.0 .0 (ivy renderer)</h1>
3636 </div>
3737 <div class="col-md-6">
3838 <div class="col-sm-6 smallpad">
@@ -94,7 +94,7 @@ export class AppComponent implements AfterViewChecked {
9494 id : number = 1 ;
9595 backup : Array < Data > = undefined ;
9696
97- constructor ( ) {
97+ constructor ( private cdRef : ChangeDetectorRef ) {
9898 console . info ( VERSION . full ) ;
9999 }
100100
@@ -125,7 +125,7 @@ export class AppComponent implements AfterViewChecked {
125125 startMeasure ( 'select' ) ;
126126 event . preventDefault ( ) ;
127127 this . selected = item . id ;
128- detectChanges ( this ) ;
128+ this . cdRef . detectChanges ( ) ;
129129 }
130130
131131 delete ( item : Data , event : Event ) {
@@ -137,41 +137,41 @@ export class AppComponent implements AfterViewChecked {
137137 break ;
138138 }
139139 }
140- detectChanges ( this ) ;
140+ this . cdRef . detectChanges ( ) ;
141141 }
142142
143143 run ( ) {
144144 startMeasure ( 'run' ) ;
145145 this . data = this . buildData ( ) ;
146- detectChanges ( this ) ;
146+ this . cdRef . detectChanges ( ) ;
147147 }
148148
149149 add ( ) {
150150 startMeasure ( 'add' ) ;
151151 this . data = this . data . concat ( this . buildData ( 1000 ) ) ;
152- detectChanges ( this ) ;
152+ this . cdRef . detectChanges ( ) ;
153153 }
154154
155155 update ( ) {
156156 startMeasure ( 'update' ) ;
157157 for ( let i = 0 ; i < this . data . length ; i += 10 ) {
158158 this . data [ i ] . label += ' !!!' ;
159159 }
160- detectChanges ( this ) ;
160+ this . cdRef . detectChanges ( ) ;
161161 }
162162
163163 runLots ( ) {
164164 startMeasure ( 'runLots' ) ;
165165 this . data = this . buildData ( 10000 ) ;
166166 this . selected = undefined ;
167- detectChanges ( this ) ;
167+ this . cdRef . detectChanges ( ) ;
168168 }
169169
170170 clear ( ) {
171171 startMeasure ( 'clear' ) ;
172172 this . data = [ ] ;
173173 this . selected = undefined ;
174- detectChanges ( this ) ;
174+ this . cdRef . detectChanges ( ) ;
175175 }
176176
177177 swapRows ( ) {
@@ -181,7 +181,7 @@ export class AppComponent implements AfterViewChecked {
181181 this . data [ 1 ] = this . data [ 998 ] ;
182182 this . data [ 998 ] = a ;
183183 }
184- detectChanges ( this ) ;
184+ this . cdRef . detectChanges ( ) ;
185185 }
186186
187187 ngAfterViewChecked ( ) {
@@ -193,8 +193,8 @@ export class AppComponent implements AfterViewChecked {
193193Object . assign ( AppComponent , { ngComponentDef : ( AppComponent as any ) . ngComponentDef } ) ;
194194
195195@NgModule ( {
196- imports : [ ] ,
197- declarations : [ AppComponent , NgForOf ] ,
196+ imports : [ CommonModule ] ,
197+ declarations : [ AppComponent ] ,
198198 bootstrap : [ AppComponent ] ,
199199} )
200200export class AppModule {
0 commit comments