ejDiagram: methods/properties can be accessed only after plugin

I was trying to look at the json produced by the :save() method  in the `OnNgInit` method of my component, but get this error instead :

ejDiagram: methods/properties can be accessed only after plugin

How do I wait for the "after plugin" before attempting to access :save() ?


public ngOnInit() {
const diagram = $("#graph").ejDiagram("instance");

console.log(diagram.save())
}

<ej-diagram height="100%" id="graph">
<e-nodes>
<e-node name ="Start" type = "flow" shape="terminator" [width]="140" [height]="50" [offsetX]="300" [offsetY]="50">
<e-nodelabels>
<e-nodelabel text="Start"></e-nodelabel>
</e-nodelabels>
</e-node>
<e-node name ="Init" type = "flow" shape="process" [width]="140" [height]="50" [offsetX]="300" [offsetY]="140">
<e-nodelabels>
<e-nodelabel text="var i = 0;"></e-nodelabel>
</e-nodelabels>
</e-node>
</e-nodes>
<e-connectors>
<e-connector name="connector1" sourceNode="Start" targetNode="Init">
<e-segments>
<e-segment type="orthogonal"></e-segment>
</e-segments>
</e-connector>
</e-connectors>

</ej-diagram>

I tried to look at the events, but couldn't find any information



3 Replies

SG Shyam G Syncfusion Team October 9, 2017 08:58 AM UTC

Hi Julian, 
 
Please use ngAfterViewInit method which triggers once the diagram is rendered. Please refer to the code example, sample and reference link to use that method. 
 
Code example: 
 
export class DiagramComponent implements AfterViewInit { 
      
            ngAfterViewInit() { 
                var diagram = $("#graph").ejDiagram("instance"); 
                var save=diagram.save(); 
                console.log(save); 
            } 
        } 
 
 
Regards, 
Shyam G 



JL Julian Lyndon-Smith October 9, 2017 09:03 AM UTC

thanks - this worked



SG Shyam G Syncfusion Team October 10, 2017 03:55 AM UTC

Hi Julian, 
Please let us know if you need further assistance on this. 
Regards, 
Shyam G 


Loader.
Up arrow icon