I have integrated a third-party JavaScript file into my app.component in the following manner:
declare var MarvinJS: any;
import { MarvinJS } from "../assets/js/marvinjslauncher.js";
Now, I am wondering if I can utilize the methods defined in marvinjslauncher.js within my app component class. If so, could you please provide guidance on how to do so? I attempted to use it like this:
export class AppComponent {
constructor() {
MarvinJS.MarvinJSUtil.getEditor("#sketch").then(function(sketcherInstance){
});
}
If there is an issue with how I am importing it, kindly advise me on that as well. Additionally, I have included the marvinjslauncher.js file in index.html. However, I am encountering the following errors:
ERROR TypeError: Cannot read property 'MarvinJSUtil' of undefined
at new AppComponent (eval at <anonymous> (bundle.js:1312), <anonymous>:16:39)
at createClass (eval at <anonymous> (bundle.js:321), <anonymous>:11007:26)
at createDirectiveInstance (eval at <anonymous> (bundle.js:321), <anonymous>:10841:37)
at createViewNodes (eval at <anonymous> (bundle.js:321), <anonymous>:12204:49)
at createRootView (eval at <anonymous> (bundle.js:321), <anonymous>:12109:5)
at callWithDebugContext (eval at <anonymous> (bundle.js:321), <anonymous>:13247:42)
at Object.debugCreateRootView [as createRootView] (eval at <anonymous> (bundle.js:321), <anonymous>:12707:12)
at ComponentFactory_.create (eval at <anonymous> (bundle.js:321), <anonymous>:10030:46)
at ComponentFactoryBoundToModule.create (eval at <anonymous> (bundle.js:321), <anonymous>:3633:29)
at ApplicationRef_.bootstrap (eval at <anonymous> (bundle.js:321), <anonymous>:5214:57)