根據我的理解,$ 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();
我沒有讓我的點對解決這將是非常讚賞的任何方向之前測試了$手錶上的屬性。