Catch diagram element via Typescript

Hey,

I'm trying to catch diagram element via Typescript according to the documentation:


But I'm getting an error-  Object is possibly 'null'

So, In order to fix it I have changed to this- 

But I'm still having an error-  Property 'ej2_instances' does not exist on type 'HTMLElement'

Can you please guide how to catch it via Typescript?


BR,

Eden



1 Reply

GG Gowtham Gunashekar Syncfusion Team July 14, 2021 01:13 PM UTC

Hi Eden, 
  
On the further analysis of the shared details, we understood that you want to take the instance of the diagram at typescript event. We suggest you to use the getInstance API to get the diagram instance at code level. We have added a sample link for your references. In the sample we have logged the diagram instance at button click. 
  
Code snippet: 
import {​​​​​​​​ getInstance }​​​​​​​​ from '@syncfusion/ej2-base';var instance = getInstance(document.getElementById('diagram'), DiagramComponent); 
 
  
 
Regards, 
Gowtham 


Loader.
Up arrow icon