首页 文章

角度为6的StaticInjectorError(AppModule)窗口

提问于
浏览
1

如何使用该窗口从该位置打开excel文件?

constructor( private fb: FormBuilder, private http: Http, private router: Router,private window:Window) { }

window.open(this.excelURL + "report/" + this.getexportlist.data.data, '_blank');

它显示了下面提到的错误:

ERROR错误:未捕获(在承诺中):错误:StaticInjectorError(AppModule)[CouponUsageReportComponent - > Window]:StaticInjectorError(Platform:core)[CouponUsageReportComponent - > Window]:NullInjectorError:没有Window的提供者!

2 回答

  • 2

    如果您使用Window对象作为依赖注入,那么您必须在某处提供它(最好是AppModule的提供者数组),或者您可以在不注入它的情况下使用它 .

  • 2

    该错误表示您已使用窗口但未在 module.ts 提供者提供者中定义:[Window]

    将其添加到 app.module.ts 中的提供商下

相关问题