0
私はAngular Version 2.1.0を使用しており、コンポーネントを動的にロードするサービスの1つを記述しています。エラーを取得していますオブジェクト型のインデックスシグネチャが暗黙的に 'any'型を持っています
私は以下のエラーが発生しました。どのように解決するのですか?
エラーTS7017オブジェクトタイプのインデックスに暗黙的に「any」タイプがあります。
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();
}
}
}
'this.appRef ['_ rootComponents'] [0] .location'はタイプ 'ElementRef'ではありません – echonax