我有这样的指示,但为什么参数 ctrl null ?
标记:
<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);
}
}
答案 0 :(得分:3)
你必须插入ng-model =&#39; htest&#39;在第一个html标签中,如
<test ng-name="htest" ng-family="hfamily" ng-model='htest'></test>