NgDiagramModelService
The NgDiagramModelService
provides methods for accessing and manipulating the diagram’s model,
Example usage
Section titled “Example usage”private modelService = inject(NgDiagramModelService);
// Add nodesthis.modelService.addNodes([node1, node2]);
Extends
Section titled “Extends”NgDiagramBaseService
Implements
Section titled “Implements”OnDestroy
Properties
Section titled “Properties”
readonly
edges:Signal
<Edge
<object
>[]>
Readonly signal of current edges in the diagram.
metadata
Section titled “metadata”
readonly
metadata:Signal
<Metadata
<object
>>
Readonly signal of current diagram metadata.
readonly
nodes:Signal
<Node
[]>
Readonly signal of current nodes in the diagram.
Methods
Section titled “Methods”addEdges()
Section titled “addEdges()”addEdges(
edges
):void
Adds new edges to the diagram.
Parameters
Section titled “Parameters”Edge
<object
>[]
Array of edges to add.
Returns
Section titled “Returns”void
addNodes()
Section titled “addNodes()”addNodes(
nodes
):void
Adds new nodes to the diagram.
Parameters
Section titled “Parameters”Node
[]
Array of nodes to add.
Returns
Section titled “Returns”void
deleteEdges()
Section titled “deleteEdges()”deleteEdges(
ids
):void
Deletes edges by their IDs.
Parameters
Section titled “Parameters”string
[]
Array of edge IDs to delete.
Returns
Section titled “Returns”void
deleteNodes()
Section titled “deleteNodes()”deleteNodes(
ids
):void
Deletes nodes by their IDs.
Parameters
Section titled “Parameters”string
[]
Array of node IDs to delete.
Returns
Section titled “Returns”void
getEdgeById()
Section titled “getEdgeById()”getEdgeById(
edgeId
):null
|Edge
<object
>
Gets an edge by id.
Parameters
Section titled “Parameters”edgeId
Section titled “edgeId”string
Edge id.
Returns
Section titled “Returns”null
| Edge
<object
>
Edge or null if not found.
getModel()
Section titled “getModel()”getModel():
ModelAdapter
Returns the current model that NgDiagram instance is using. Returns null if flowCore is not initialized.
Returns
Section titled “Returns”getNearestNodeInRange()
Section titled “getNearestNodeInRange()”getNearestNodeInRange(
point
,range
):null
|Node
Gets the nearest node in a range from a point.
Parameters
Section titled “Parameters”Point to check from.
number
Range to check in.
Returns
Section titled “Returns”null
| Node
Nearest node in range or null.
getNearestPortInRange()
Section titled “getNearestPortInRange()”getNearestPortInRange(
point
,range
):null
|Port
Gets the nearest port in a range from a point.
Parameters
Section titled “Parameters”Point to check from.
number
Range to check in.
Returns
Section titled “Returns”null
| Port
Nearest port in range or null.
getNodeById()
Section titled “getNodeById()”getNodeById(
nodeId
):null
|Node
Gets a node by id.
Parameters
Section titled “Parameters”nodeId
Section titled “nodeId”string
Node id.
Returns
Section titled “Returns”null
| Node
Node or null if not found.
getNodesInRange()
Section titled “getNodesInRange()”getNodesInRange(
point
,range
):Node
[]
Gets all nodes in a range from a point.
Parameters
Section titled “Parameters”Point to check from.
number
Range to check in.
Returns
Section titled “Returns”Node
[]
Array of nodes in range.
toJSON()
Section titled “toJSON()”toJSON():
string
Serializes the current model to a JSON string.
Returns
Section titled “Returns”string
The model as a JSON string.
updateEdge()
Section titled “updateEdge()”updateEdge(
edgeId
,edge
):void
Updates the properties of an edge.
Parameters
Section titled “Parameters”edgeId
Section titled “edgeId”string
Edge id.
Partial
<Edge
>
New edge properties.
Returns
Section titled “Returns”void
updateEdgeData()
Section titled “updateEdgeData()”updateEdgeData<
T
>(edgeId
,data
):void
Updates the data of an edge.
Type Parameters
Section titled “Type Parameters”T
extends undefined
| Record
<string
, unknown
>
Parameters
Section titled “Parameters”edgeId
Section titled “edgeId”string
Edge id.
T
New data to set for the edge (can be strongly typed).
Returns
Section titled “Returns”void
updateEdges()
Section titled “updateEdges()”updateEdges(
edges
):void
Updates multiple edges at once.
Parameters
Section titled “Parameters”Pick
<Edge
<object
>, "id"
> & Partial
<Edge
<object
>>[]
Array of edge updates (must include id and any properties to update).
Returns
Section titled “Returns”void
updateNode()
Section titled “updateNode()”updateNode(
nodeId
,node
):void
Updates the properties of a node.
Parameters
Section titled “Parameters”nodeId
Section titled “nodeId”string
Node id.
Partial
<Node
>
New node properties.
Returns
Section titled “Returns”void
updateNodeData()
Section titled “updateNodeData()”updateNodeData<
T
>(nodeId
,data
):void
Updates the data of a node.
Type Parameters
Section titled “Type Parameters”T
extends undefined
| Record
<string
, unknown
>
Parameters
Section titled “Parameters”nodeId
Section titled “nodeId”string
Node id.
T
New data to set for the node (can be strongly typed).
Returns
Section titled “Returns”void
updateNodes()
Section titled “updateNodes()”updateNodes(
nodes
):void
Updates multiple nodes at once.
Parameters
Section titled “Parameters”Pick
<Node
, "id"
> & Partial
<Node
>[]
Array of node updates (must include id and any properties to update).
Returns
Section titled “Returns”void