I am using Angular Version 2.1.0 and writing one of service to load a component dynamically.
I an getting below error, how to resolve it?
Error TS7017 Index signature of object type implicitly has an 'any' type.
import { Injectable, ComponentFactoryResolver, ApplicationRef, ElementRef, ViewContainerRef } from '@angular/core';
import { SpinnerComponent } from '../components/blockui/blockui.component';
@Injectable()
export class SpinnerService {
spinnerComp: ViewContainerRef;
constructor(private componentLoader: ComponentFactoryResolver, private appRef: ApplicationRef) { }
public start() {
//error in this line?
let elementRef: ElementRef = this.appRef['_rootComponents'][0].location;
return this.startInside(elementRef, null);
}
public startInside(elementRef: ElementRef, anchorName: string) {
let spinnerRef = (!anchorName) ?
this.componentLoader.resolveComponentFactory.call(SpinnerComponent, elementRef) :
this.componentLoader.resolveComponentFactory.call(SpinnerComponent, elementRef, anchorName);
spinnerRef.then((compRef: ViewContainerRef) => {
this.spinnerComp = compRef;
});
}
public stop() {
if (this.spinnerComp) {
this.spinnerComp.detach();
}
}
}