docs(aio): Clearing array with [] (#20369) (#20395)

Convert remaining references to directly use LoggerServices logs.

PR Close #20395
This commit is contained in:
Shavi Pathania 2017-11-16 21:03:54 +05:30 committed by Miško Hevery
parent 697fb76960
commit 949836d003
2 changed files with 6 additions and 10 deletions

View File

@ -93,22 +93,20 @@ export class AfterContentComponent implements AfterContentChecked, AfterContentI
<h4>-- AfterContent Logs --</h4> <h4>-- AfterContent Logs --</h4>
<p><button (click)="reset()">Reset</button></p> <p><button (click)="reset()">Reset</button></p>
<div *ngFor="let msg of logs">{{msg}}</div> <div *ngFor="let msg of logger.logs">{{msg}}</div>
</div> </div>
`, `,
styles: ['.parent {background: burlywood}'], styles: ['.parent {background: burlywood}'],
providers: [LoggerService] providers: [LoggerService]
}) })
export class AfterContentParentComponent { export class AfterContentParentComponent {
logs: string[];
show = true; show = true;
constructor(private logger: LoggerService) { constructor(public logger: LoggerService) {
this.logs = logger.logs;
} }
reset() { reset() {
this.logs = []; this.logger.clear();
// quickly remove and reload AfterContentComponent which recreates it // quickly remove and reload AfterContentComponent which recreates it
this.show = false; this.show = false;
this.logger.tick_then(() => this.show = true); this.logger.tick_then(() => this.show = true);

View File

@ -95,22 +95,20 @@ export class AfterViewComponent implements AfterViewChecked, AfterViewInit {
<h4>-- AfterView Logs --</h4> <h4>-- AfterView Logs --</h4>
<p><button (click)="reset()">Reset</button></p> <p><button (click)="reset()">Reset</button></p>
<div *ngFor="let msg of logs">{{msg}}</div> <div *ngFor="let msg of logger.logs">{{msg}}</div>
</div> </div>
`, `,
styles: ['.parent {background: burlywood}'], styles: ['.parent {background: burlywood}'],
providers: [LoggerService] providers: [LoggerService]
}) })
export class AfterViewParentComponent { export class AfterViewParentComponent {
logs: string[];
show = true; show = true;
constructor(private logger: LoggerService) { constructor(public logger: LoggerService) {
this.logs = logger.logs;
} }
reset() { reset() {
this.logs = []; this.logger.clear();
// quickly remove and reload AfterViewComponent which recreates it // quickly remove and reload AfterViewComponent which recreates it
this.show = false; this.show = false;
this.logger.tick_then(() => this.show = true); this.logger.tick_then(() => this.show = true);