I am trying to access a method from an external js(jQuery) file in an angular 7 component and I have tried many ways but I am not able to call that method in an external file. Below is my code:
external file:
> (function ($) {
var makeLink = function (infos) {
if (oneToMany == "off") {
// If the link already exists then we erase it
eraseLinkA(infos.offsetA);
eraseLinkB(infos.offsetB);
}
linksByOrder.push({ "from": infos.offsetA, "to": infos.offsetB });
linksByName.push({ "from": infos.nameA, "to": infos.nameB });
draw();
$("body").trigger({
type: "fieldLinkerUpdate",
what: "addLink"
});
}
}(jQuery));
ts file:
import * as abcJS from '../external.js';
import * as $ from 'jquery';
declare var makeLink: any;
declare var jQuery: any;
export class FieldMappingComponent implements OnInit, AfterViewInit {
constructor(public templateService: TemplateService, private route: ActivatedRoute) { }
ngOnInit() {
this.route.paramMap.subscribe(params => {
this.templateId = params.get('id');
});
ngAfterViewInit() {
makeLink({offsetA: 0, nameA: 'Date', offsetB: 1, nameB: 'settlement-end-date'});
}
}
I am not getting where I am going wrong. any suggestions may help. Thanks in advance.