docs(core): correct code examples for ChangeDetectorRef
This commit is contained in:
parent
5e840e1e79
commit
856278cfea
|
@ -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,15 +166,16 @@ 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();
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* @Component({
|
* @Component({
|
||||||
* selector: 'app',
|
* selector: 'app',
|
||||||
|
|
Loading…
Reference in New Issue