A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/typed-mxgraph/typed-mxgraph/issues/50 below:

Type Error is thrown on invoking fatory function imported from mxgraph in Angular 13 · Issue #50 · typed-mxgraph/typed-mxgraph · GitHub

Following type error is thrown while invoking factory function imported from mxgraph

Uncaught TypeError: Cannot set properties of undefined (setting 'mxBasePath')

This happens only on Angular 13 stable version and not on angular 12.

Please see the below public repository link & code snippets for reference
https://github.com/Dhawaldeep/mxgraph-angular-tteen

src/app/mxgraph-engine/mxgraph.ts

import factory from 'mxgraph';
declare global {
  interface Window {
    mxBasePath: string;
  }
}

window['mxBasePath'] = '../../assets/mxgraph';

export default factory({
  mxBasePath: '../../assets/mxgraph',
});

src/app/mxgraph-engine/index.d.ts

declare module 'mxgraph';

src/app/app.component.ts

.........
import mx from './mxgraph-engine/mxgraph';
import '@typed-mxgraph/typed-mxgraph';
.........
export class AppComponent implements AfterViewInit {
  @ViewChild('mxgraphEl') mxgraphEl: ElementRef<HTMLDivElement>;

  ngAfterViewInit(): void {
    if(mx.mxClient.isBrowserSupported()) {
      console.log('Yes! Yes!');
    }
    const graph = new mx.mxGraph(this.mxgraphEl.nativeElement);
    const model = graph.getModel();
    model.beginUpdate();
    try {
      graph.insertVertex(graph.getDefaultParent(), '', 'TEST', 0, 0, 100, 100);
    } finally {
      model.endUpdate();
    }
  }
}

src/app/app.component.html

package.json

....
dependencies: {
..,,.
 "mxgraph": "^4.2.2",
....
},
.....
devDependencies: {
.....
"@typed-mxgraph/typed-mxgraph": "^1.0.5",
.....
}

Thank you.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4