I'm incorporating a third-party JavaScript library into my .NET Core ASP Angular application. This library executes its functionality within the $(document).ready method. However, I've encountered an issue where the library's logic isn't being applied correctly when navigating to an Angular route because the $(document).ready method isn't triggering.
To address this problem, I have included the external JavaScript library in the scripts section of my angular-cli configuration.
In an attempt to resolve the issue, I edited the third-party JavaScript file and added a method that calls the same logic as the one triggered in the document ready event. Now, I'm facing difficulty figuring out how to invoke this method from my Angular TypeScript component.
To simplify and test the solution, I created a basic JavaScript file named Tester.js, which is listed in my -angular-cli.json under the scripts tag:
(function ($) {
"use strict";
$(document).ready(function () {
CallMe();
});
function CallMe(){
console.log('HEY I GOT CALLED');
}
})(jQuery);
My goal is to trigger the CallMe() method from within a TypeScript component file. While the CallMe() method successfully fires once on the document.ready event, I am struggling to find a way to execute it dynamically from my TypeScript scripts.
Do you have any suggestions or ideas on how to achieve this?