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