How to define linkTemplateMap inside a directive in AngularJS?

        linkTemplate: $(go.Link, {
            layerName: "Foreground",
            fromEndSegmentLength: 15,
            toEndSegmentLength: 15
        }, {
            fromSpot: go.Spot.Right,
            toSpot: go.Spot.Left
        }, {
            resegmentable: true,
            relinkableFrom: true,
            relinkableTo: true,
            toShortLength: 4
        },

        $(go.Shape,
            new go.Binding("opacity", "hideconnection", function(t) {
                return t ? 1 : 0;
            }), {
                stroke: "lightgray",
                name: "common-mapping",
                opacity: 1
            }),
        $(go.Shape, {
            toArrow: "Triangle",
            segmentOffset: new go.Point(5, 0),
            fill: colors.green,
            strokeWidth: 0
        }),
        $(go.Shape, {
            fromArrow: "Triangle",
            segmentOffset: new go.Point(-5, 0),
            fill: colors.green,
            strokeWidth: 0
        })),

  linkTemplateMap: this.linkTemplateMap.add("Mapping", $(go.Link, 
      { isTreeLink: false, isLayoutPositioned: false, layerName: "Foreground" },
      { fromSpot: go.Spot.Right, toSpot: go.Spot.Left },
      { relinkableFrom: true, relinkableTo: true,
  toMaxLinks : 1, fromMaxLinks: 1},
      $(go.Shape, { stroke: "blue", strokeWidth: 2 })
    ));

Doesn’t work!

Map | GoJS API returns a boolean, not a Map.

Thank You. Works for Me.