Labels Links with key value

The following example like this: UML Class Nodes

I try to set a Label in Link and write some code like this
linkTemplate $(go.TextBlock, “value I want”, { segmentOffset: new go.Point(0, -10) })

myDiagram.linkTemplate =
  $(go.Link,
    { routing: go.Link.AvoidsNodes },
    new go.Binding("isLayoutPositioned", "relationship", convertIsTreeLink),
    $(go.Shape),
    $(go.Shape, { scale: 1.3, fill: "white" },
      new go.Binding("fromArrow", "relationship", convertFromArrow)),
    $(go.Shape, { scale: 1.3, fill: "white" },
      new go.Binding("toArrow", "relationship", convertToArrow)),
    $(go.TextBlock, "value I want to add", { segmentOffset: new go.Point(0, -10) }),
  );

In second parameter(value I want to add) , I want to use nodedata[0][“key”] to get key data but not work

How to solve this problem with javascript or gojs API such as getLabelKeysForLinkData?

var nodedata = [
  {
    key: 1,
    name: "BankAccount",
    properties: [
      { name: "owner", type: "String", visibility: "public" },
      { name: "balance", type: "Currency", visibility: "public", default: "0" }
    ],
    methods: [
      { name: "deposit", parameters: [{ name: "amount", type: "Currency" }], visibility: "public" },
      { name: "withdraw", parameters: [{ name: "amount", type: "Currency" }], visibility: "public" }
    ]
  },
  {
    key: 11,
    name: "Person",
    properties: [
      { name: "name", type: "String", visibility: "public" },
      { name: "birth", type: "Date", visibility: "protected" }
    ],
    methods: [
      { name: "getCurrentAge", type: "int", visibility: "public" }
    ]
  },
  {
    key: 12,
    name: "Student",
    properties: [
      { name: "classes", type: "List", visibility: "public" }
    ],
    methods: [
      { name: "attend", parameters: [{ name: "class", type: "Course" }], visibility: "private" },
      { name: "sleep", visibility: "private" }
    ]
  },
  {
    key: 13,
    name: "Professor",
    properties: [
      { name: "classes", type: "List", visibility: "public" }
    ],
    methods: [
      { name: "teach", parameters: [{ name: "class", type: "Course" }], visibility: "private" }
    ]
  },
  {
    key: 14,
    name: "Course",
    properties: [
      { name: "name", type: "String", visibility: "public" },
      { name: "description", type: "String", visibility: "public" },
      { name: "professor", type: "Professor", visibility: "public" },
      { name: "location", type: "String", visibility: "public" },
      { name: "times", type: "List", visibility: "public" },
      { name: "prerequisites", type: "List", visibility: "public" },
      { name: "students", type: "List", visibility: "public" }
    ]
  }
];

Use a Binding. GoJS Data Binding -- Northwoods Software

But it isn’t clear to me how it would make sense for each link to depend on one particular node’s data property.

@walter

Just beginning I want get nodedata with key and output in label link,after think carefully
I need to make the order with Flow chart,

Well… ,Just like this
When 1 to 2, I add Label link with 1,
When 2 to 3, I add Label link with 2,

When 1 to 5, I add Label link with 5,

var linkdata = [
  { from: 1, to: 2, relationship: "generalization" },
  { from: 2, to: 3, relationship: "generalization" },
  { from: 3, to: 4, relationship: "aggregation" },
  { from: 4, to: 1, relationship: "generalization"}
  { from: 1, to: 5, relationship: "generalization"}
];

So I need to bind nodedata property to do this?

If you want a property of an object in your link template to always get a value from the Link.fromNode.data object, that can be arranged. But I don’t understand how to decide sometimes from the Link.fromNode and sometimes from the Link.toNode, as your example shows.

Instead of trying to use a complex Binding, it might be easier to implement “LinkDrawn” and “LinkRelinked” DiagramEvent listeners to modify the Link’s TextBlock.text directly with whatever you decide to use. Use a simple binding:
new go.Binding(“text”).makeTwoWay()
on the link’s TextBlock to make sure the string is saved in the model.