Reputation: 3605
I am having a runtime error where it gives me the stack trace of defaultView
in my angular app, and it prevents me from moving on in my project.
The error: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'defaultView' of undefined
TypeError: Cannot read property 'defaultView' of undefined
I have googled this, but none of the questions have angular in them. So I think this is the first one about defaultView
with angular.
I have some code that takes an address and outputs a marker on to the map. I got the error from https://developers.google.com/maps/documentation/javascript/geocoding
Code in Stackblitz: https://stackblitz.com/edit/angular-gib2mq.
index.d.ts in the root folder makes the import statement work: import { } from 'googlemaps';
declare module "googlemaps";
I also have @types/googlemaps
installed through npm install --save @types/googlemaps
I want to the error to go away, but it happens every time I run my app.
Thanks!
Upvotes: 0
Views: 3251
Reputation: 407
Looks like you have a pretty big misunderstanding of how to use the @agm package. That's okay! Some notes:
Working stackblitz (minus the API key): https://stackblitz.com/edit/angular-yebacm
Good luck!
edit: you also don't need declare module "googlemaps";
Upvotes: 1