I'm going to import this d3gauge.js file into one of my angular2 component, memmon.component.ts
file.
import '../../../../js/d3gauge.js';
export class MemMonComponent {
createMemGauge() {
new drawGauge(this.opt); //drawGauge() is a function inside d3gauge.js
}
}
and in the corresponding template file, add
<script src="../../../../js/d3gauge.js"></script>
But it doesn't work, drawGauge
can't be found.
So,
- what're correct steps to import an external js file to angular2?
- since I'm using webpack, is it possible to do it in webpack? I refer to this question , the webpack solution there doesn't work for me as a result of
.ensure
can't be resolved.