3

ディレクティブリンク機能があります。デフォルトでは、Angular リンク関数はポスト リンク関数ですよね。それをプレリンクにする方法は?

app.directive("textBoxCol", function () {
        return {
            require: "^grid",
            restrict: "E",
            replace: true,
            scope: {
                title: "@title",
                cssClass: "@class",
                dataField: "@field"
            },
            link: function ($scope, element, attrs, grid) {
                $scope.type = ColumnType.TextBox;
                tableControl.addColumn($scope);
            }
        };
    });

ところで、require を使用します。

4

1 に答える 1

0

compile関数を実装し、そこから関数を返す必要がありますprelink

Angular のドキュメント ( https://docs.angularjs.org/api/ng/service/%24compile ) から取得:

compile: function compile(tElement, tAttrs, transclude) {
  return {
    pre: function preLink(scope, iElement, iAttrs, controller) { ... },
    post: function postLink(scope, iElement, iAttrs, controller) { ... }
  }
  // or
  // return function postLink( ... ) { ... }
},
于 2015-11-24T12:23:43.877 に答える