I am using material design and Angular 5. I was trying to use the material loader, so when navigation start show loader and when ends remove loader as per the answer in this question. I tried viewchild
by
<mat-progress-bar #spinnerElement [mode]="'indeterminate'" [color]="'primary'"></mat-progress-bar>
and called in my component constructor as below:
@ViewChild('spinnerElement')
spinnerElement: ElementRef;
constructor(
.....
private ngZone: NgZone,
private renderer: Renderer) {
console.log(this.spinnerElement, 'spinnerElement');
}
But console always returns undefined
. Bit new to Angular. Any idea why guys?