How to get link label

I want to ask you how can I get the text of a link
I tried after converting to json
but is displayed undefined
when I tried
myObj.nodeDataArray[0].text it displayed the text for the first node

That depends entirely on your link template and the link data.

I added a textblock in the template and binding to “text”
but is does not work

Then if myLink is a reference to a Link, then will get you that string.

myDiagram.linkTemplate =
$(go.Link, // the whole link panel
curve: go.Link.Bezier, adjusting: go.Link.Stretch,
reshapable: true, relinkableFrom: true, relinkableTo: true,
toShortLength: 3
new go.Binding(“points”).makeTwoWay(),
new go.Binding(“curviness”),
$(go.Shape, // the link shape
{ strokeWidth: 1.5 }),
$(go.Shape, // the arrowhead
{ toArrow: “standard”, stroke: null }),
$(go.Panel, “Auto”,
$(go.Shape, // the label background, which becomes transparent around the edges
fill: $(go.Brush, “Radial”,
{ 0: “rgb(240, 240, 240)”, 0.3: “rgb(240, 240, 240)”, 1: “rgba(240, 240, 240, 0)” }),
stroke: null
$(go.TextBlock, “transition”, // the label text
textAlign: “center”,
font: “9pt helvetica, arial, sans-serif”,
margin: 4,
editable: true // enable in-place editing
// editing the text automatically updates the model data
new go.Binding(“text”).makeTwoWay())

this is the link template. I want when the user draws link I want to get the label of the link
there is only to,from,points properties for the link I could not find text property

Let’s be precise in the terminology that we are using.

The “label” for a Link in this case will be an “Auto” Panel that contains a TextBlock.

But you are asking for a text string. That TextBlock shows its TextBlock.text string, which is data bound to the data.text property of the model data. That is why will get you the text string that you asked for.

I guess if that value is undefined, then the string that the user sees is “transition”, because that is the default value for that TextBlock.text.

when I convert diagram to json, for link there is to, from, points properties. can I get text property for the link as well

Either the property is there on the link data, in which case you have the string value, or the property is not there, in which case the model does not have the string value being shown in the link label.

The Diagram is a “view” of the Model. You can change templates and have arbitrarily different appearances for the links or for the nodes for exactly the same model data. It’s the model that provides the “truth” to what information is there, so if some property isn’t set on the model data, it’s not there at all. You cannot expect the model to know how it is being rendered.

thank you very much for your efforts