Revathi Vijay
Revathi Vijay

Reputation: 1308

StaticInjectorError(AppModule) window in angular 6

How to open excel file from the location using the window?

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

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

It shows the below mentioned error:

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[CouponUsageReportComponent -> Window]: StaticInjectorError(Platform: core)[CouponUsageReportComponent -> Window]: NullInjectorError: No provider for Window!

Upvotes: 1

Views: 2291

Answers (2)

Sajeetharan
Sajeetharan

Reputation: 222722

The error says you have used window but not defined in your module.ts Provider ex providers: [Window]

Add it under providers in your app.module.ts

Upvotes: 3

kzrfaisal
kzrfaisal

Reputation: 1443

If you are using Window object as a dependency injection then you have to provide it somewhere (preferably AppModule's provider array), or you can use it without injecting it.

Upvotes: 2

Related Questions