Currently, I am integrating the fantastic Drawflow library created by @Jerosoler (available at: https://github.com/jerosoler/Drawflow) into my PrimeNg project.
User @BobBDE has provided typescript definitions for this library here: https://www.npmjs.com/package/@types/drawflow
My project utilizes PrimeNg with Angular 11 and Typescript 4.
I have successfully installed both the library and the definitions using npm commands. Everything seems to be in order as I can locate the JS library, and the definitions to use within Typescript.
Nevertheless, I am encountering an undefined error and I am having difficulty identifying what could possibly be incorrect...
In my component's HTML, I have included the following:
<div #drawflowDiv></div>
To access the div in my component's Typescript:
@ViewChild('drawflowDiv', {static: true})
drawflowDiv: HTMLElement;
Subsequently, in my ngOnInit function, I have the following setup:
ngOnInit(): void {
console.log(this.drawflowDiv);
const editor = new drawflow(this.drawflowDiv);
editor.reroute = true;
editor.editor_mode = 'edit';
editor.drawflow = {.....}; // Default example JSON for the library
editor.start();
}
There are no errors evident in the code, and the drawflow library is correctly connected. The console.log provides all the details of the HTML element within the div, indicating that it is not undefined. A screenshot of the console log is attached to this post.
Your assistance would be greatly appreciated, and I hope that someone here might have a solution.
Thanks in advance!