根据我的理解,$ attr。$观察到一次发生火灾。所以有时候在属性上使用$ watch。我期待的单元测试,需要ngModel
scope.$watch(attr.ngModel, function (newValue) {
minlength = parseInt(attr.minLength);
scope.minLengthValidator(newValue);
});
因为这好像我可以调用$消化Link功能使用范围指令。
我嘲笑属性开始是这样的...
html = angular.element("<input ng-model=\"myUnit\" min-length=\"3\">");
我不知道如果我可以重新定义element.attr(“最小长度”)我的规范的内部并运行$消化,或者自从手表通过新的价值以来,有一种更复杂的方法。
我的模拟设置的其余部分是像这样
$rootScope = $rootScope.$new();
element = $compile(html)($rootScope);
$rootScope.$digest(element);
controller = element.controller('ngModel');
scope = element.scope();
我没有让我的点对解决这将是非常赞赏的任何方向之前测试了$手表上的属性。