Articles in this section
Category / Section

How to Update the Node Data at Runtime in Angular Diagram Layout?

2 mins read

In this article, you can learn about how to update the node data at runtime in an Angular diagram layout. The Angular Diagram allows you to dynamically update the node data in the layout (such as annotations or labels) at runtime. In this guide, we will demonstrate how to update the content of a selected node programmatically.

To modify the content of a node dynamically, you can use the content property of the node’s shape.

Below is a code example that shows how to update the node data at runtime when node Data button is clicked.

nodedata() {
// Check if any node is selected
   if (this.diagram.selectedItems.nodes.length > 0) {
// Dynamically update the node content
     (this.diagram.selectedItems.nodes[0].shape as any).content = 'Head of the board';
     this.diagram.dataBind();
   }
 } 

==> Check for Selected Node: We use diagram.selectedItems.nodes.length to check if any node is selected in the diagram.

==> Update Node Content: If a node is selected, we modify the content property of the node’s shape. In this example, the content is set to ‘Head of the Board’.

Sample: You can try this code example in the following stackBlitz

Conclusion

We hope you enjoyed learning how to update the node data at runtime in Angular Diagram layout.

You can refer to our Angular Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied