docs(core): correct code examples for ChangeDetectorRef

This commit is contained in:
Daniel Kucal 2017-08-13 16:52:44 +02:00 committed by Hans
parent 5e840e1e79
commit 856278cfea
1 changed files with 7 additions and 6 deletions

View File

@ -28,7 +28,7 @@ export abstract class ChangeDetectorRef {
* *
* constructor(private ref: ChangeDetectorRef) { * constructor(private ref: ChangeDetectorRef) {
* setInterval(() => { * setInterval(() => {
* this.numberOfTicks ++ * this.numberOfTicks++;
* // the following is required, otherwise the view will not be updated * // the following is required, otherwise the view will not be updated
* this.ref.markForCheck(); * this.ref.markForCheck();
* }, 1000); * }, 1000);
@ -78,11 +78,11 @@ export abstract class ChangeDetectorRef {
* @Component({ * @Component({
* selector: 'giant-list', * selector: 'giant-list',
* template: ` * template: `
* <li *ngFor="let d of dataProvider.data">Data {{d}}</lig> * <li *ngFor="let d of dataProvider.data">Data {{d}}</li>
* `, * `,
* }) * })
* class GiantList { * class GiantList {
* constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) { * constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {
* ref.detach(); * ref.detach();
* setInterval(() => { * setInterval(() => {
* this.ref.detectChanges(); * this.ref.detectChanges();
@ -166,13 +166,14 @@ export abstract class ChangeDetectorRef {
* template: 'Data: {{dataProvider.data}}' * template: 'Data: {{dataProvider.data}}'
* }) * })
* class LiveData { * class LiveData {
* constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {} * constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {}
* *
* set live(value) { * set live(value) {
* if (value) * if (value) {
* this.ref.reattach(); * this.ref.reattach();
* else * } else {
* this.ref.detach(); * this.ref.detach();
* }
* } * }
* } * }
* *