首页 > 解决方案 > window['angularComponentReference'] 显示类型错误

问题描述

我正在尝试在 Angular 项目中使用 NgZone:

constructor(
   private fishboneService: FishboneService,
   private zone: NgZone,
) {
  window['angularComponentReference'] = {
    zone: this.zone, 
    componentFn: (value: any) => this.getDataFromOutside(value), 
    component: this
  };
  console.log('reference added');
}

但我收到以下错误:

元素隐式具有“任何”类型,因为索引表达式不是“数字”类型。

19 窗口['angularComponentReference'] = {

标签: angulartypescript

解决方案


推荐阅读