Forum Discussion

frank_guarino_murata_com's avatar
1 year ago

How to import javascript classes into another javascript method?

I have a JavaScript class which I created and I want to instantiate this class in another javascript method

i.e.

F2:

export
default class Example { test() { console.log('hello world'); } }



& F1:
import
Example from './file2';

var myInstance = new Example() myInstance.test()




I have not been able to do this yet, and I'll likely need to find another way, but does anyone know? I am aware of aras.evalMethod, although I have yet to find success in terms of class instantiation with this way.

1 Reply

  • angela's avatar
    angela
    Catalyst II

    Hi Frank,

    good question! I so far didn´t succeed to use anything with "export" in my code.

    Currently I use following two ways to embed external libs:

    1. https://aras.com/en/blog/display-workflow-timeline-using-vis-js - See code sample

    2. If the concept shown in this blog post code doesn´t work for whatever reason, I directly embed the class in the Form inside an html element. This works always. But I prefer the variant in the blog post, cause custom libs references in Methods are easier to see.