Skip to content

Instantly share code, notes, and snippets.

@iraghumitra
iraghumitra / streamline-icon.component.html
Last active June 1, 2021 06:00
Streamline Icons Angular
<span [innerHTML]="svgContent" (click)="onClick($event)" [ngClass]="(fill.length > 0 || stroke.length > 0) ? '' : 'icon-bg'" #element></span>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@iraghumitra
iraghumitra / angular-datamap-world.md
Last active August 8, 2018 18:53
Datamap component in angular

The gist captures my approch forcreating an angular component for Datamap. I did'nt want to include d3 or topojson in my angular.json file or the index.html file since doing so would import them during initial page load which is redundant for me.

The other approches i tried involved importing d3, topojson and datamap in my component file, the problem that i faced with that approch is

  • d3 and topojson imports were getting ignored (i guess this should be the work of angular compilere since i am not refereing them in my component).
  • Datamap din't really have a very ts compatible index files

So finally i created a service that would import d3, topojson and datamap, inject the service into the component. In the ngOnInit method get the instance of d3 and topojson and assign them to window window and initialise the datamap. This would creat datamap on the browser. Once datamap is created unset d3 and topojson from the window scope.