I am currently trying to implement the awesome library Drawflow made by @Jerosoler (found here: https://github.com/jerosoler/Drawflow) inside my PrimeNg project.
Awesome user, @BobBDE made the typescript definition for this library here: https://www.npmjs.com/package/@types/drawflow
My project use PrimeNg with angular 11 and typescript 4.
I have used the 2 npm commands to install the library and the definitions. Everything is looking great. I can definetly find the JS library, and the definitions and use them inside Typescript.
However, I have an undefined error and I am struggling to find what am I doing wrong...
Inside my component html I have the following:
<div #drawflowDiv></div>
Retrieving the div inside my component typescript:
@ViewChild('drawflowDiv', {static: true})
drawflowDiv: HTMLElement;
Then inside my ngOnInit I have the following:
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();
}
I do not have any error anywhere in the code, the drawflow library is correctly linked. The console.log give me all the details of the div html element so it's not undefined. You'll find the screenshot of the console joined as a screenshot on this post.
Thank you in advance and hoping that maybe somebody here has a solution.
Thanks in advance!