为什么我指令中的 ctrl 为空?

Why ctrl in my directive is null?

我有这样的指令,但为什么参数 ctrlnull?

标记:

<test ng-name="htest" ng-family="hfamily" ></test>

指令:

 var tmp = "<input   type='text' ng-model='htest' >";

return {
    restrict: 'AE',
    template: tmp,
    require: "^?ngModel",
    scope: {
        name: "=ngName",
        family:"=ngFamily"
    },
    link: function (scope, element, attrs, ctrl) {
        console.log("aaaaaaaaaaaaaaa", ctrl);

    }
}

您必须在第一个 html 标签中插入 ng-model='htest',例如

<test ng-name="htest" ng-family="hfamily" ng-model='htest'></test>