When i use any of the mxgraph methods/values my mxgraph is 'undefined'
I already tried the viks answer on this thread : How to integrate mxGraph with Angular 4?
but even if this give me the typings and intellisense is working fine i still have my mxgraph undefined.
I should mention that this is a brand new angular project and i just followed viks's tutorial to get here.
import { mxgraph } from "mxgraph";
declare var require: any;
const mx = require('mxgraph')({
mxBasePath: 'assets/mxgraph'
});
@Component({...})
export class LetestComponent implements OnInit {
ngOnInit() {
var container = document.getElementById('graphContainer');
var graph = new mx.mxGraph(container);
}
}
with this in the HTML file
<div id="graphContainer"></div>
I shouldn't have any error there and i should be able to use mx to call any mxGraph methods.
When i compile the code it seems to be working fine, but then when i look at it on the browser's console i have :
"Uncaught TypeError: Cannot set property 'mxBasePath' of undefined at build.js:11 at Module../src/app/letest/letest.component.ts (letest.component.ts:6)"
I don't know if it's a problem because i'm using angular 8 where viks's answer is for angular 4 or if it's something with the typescript syntax which could have changed since then.
If someone could help me with this it would be awesome,
thanks in advance !
Edit: i'm still trying a bunch of things but i think i don't really understand the "require('mxgraph')" part, it's in there that there is the undefined even thought the mx constant is not undefined if i log it to the console in the class. Maybe there's a new way in angular 8 to do the same thing?
I should also mention that the Types of mxgraph seems to be working fine in Visual Code studio, it's like i have the definitions but not the actual code.
Edit 2: After diving in a bit more i got it working with https://itnext.io/how-to-integrate-mxgraph-with-angular-6-18c3a2bb8566 but the problem is that these Types are 4 years old so it lack a huge numbers of methods/variables from the latest mxgraph version.
What i found out is that in these types there's just (Is Working)
declare class mxGraph{..}
Whereas the newest Types use (Is not working)
declare namespace mxgraph {
export class mxGraph {..}
}
Could someone explain the differences please?