Hi, I’ve made a functional application with gojs using javascript, and now I want to integrate it on an Angular project, but I can’t do it. When I try to run the init() function on angular it throws me the next errors:
What can I do? Thank you.
Hi, I’ve made a functional application with gojs using javascript, and now I want to integrate it on an Angular project, but I can’t do it. When I try to run the init() function on angular it throws me the next errors:
The error is saying that you haven’t loaded the GoJS library yet, which is what defines the “go” namespace.
Copy the Figures.js file, or perhaps more likely, the extensionsTS/Figures.js file if you are using TypeScript, into your own directory, and then make sure it imports the same “go.js” or “go-debug.js” file as the rest of your code.
Hi Walter, and thank you for your reply, but I think that it should be loaded, i’ve installed “gojs” and “gojs-angular”. I’m new using angular and maybe I’m missing something. my code is:
import { Com ponent, OnInit } from '@angular/core';
Preformatted textimport * as go from 'gojs';
declare const init: any;
@Component({
selector: 'app-diagram-creator',
templateUrl: './diagram-creator.component.html',
styleUrls: ['./diagram-creator.component.css']
})
export class DiagramCreatorComponent implements OnInit {
public myDiagram;
public tree;
public activity = 1;
public sentence = 1;
public forLoop = 1;
public ifCond = 1;
public functionNumber = 1;
public code = '';
constructor() { }
ngOnInit(): void {
init();
}
}
where init is the js method, I’ve added all the js files on the project and in the angular.json scripts section.
That’s fine, but apparently you are also loading the “Figures.js” extension, and that is what is complaining. That is why I suggested using extensionsTS/Figure.ts and making sure its import matches what you are using.
oh okay sorry my bad, and where can I find extensionsTS/Figure.ts? because I searched for it and i found nothing, sorry if it is an stupid question
There are three directories of extensions, named: extensions
(traditional JavaScript), extensionsTS
(TypeScript), and extensionsJSM
. Copy whichever source file you find most suitable for your project.
Found it! I still have some errors, but I’ll try to fix them by my way, thank you so much for the quick answer and your patience