Open shahin4u000 opened 2 years ago
I also faced this problem after angular ^12 update. Seems like npm i datamaps
that package is not compatible with the recent changes on angular. So i did a work around.
copy the necessary files in assets folder and add in angular.json
"scripts": [ "node_modules/jquery/dist/jquery.min.js", "src/assets/lib/datamaps/d3.min.js", "src/assets/lib/datamaps/topojson.js", "src/assets/lib/datamaps/datamaps.world.lores.js" ],
in your component or service where ever you are using it
declare var d3:any; declare var Datamaps:any;
on top and you are good to go
I use this https://www.npmjs.com/package/angular-datamaps to use datamaps within Angular. Maybe that helps?
After installed with
npm i datamaps
I have modified my angular.json file like that:angular component I was using like that:
component.ts file
declare var Datamap: any;
# outside the component, to say the typescript it is defined somewhere in the appand then put my code in a lifecycle hook like that:
but unfortunately, It did not load anything. I am getting an error in the console that:
datamap
is undefined.Can someone please help me to fix that problem?