基本的に要素の値を監視するディレクティブがあります。
この要素にはng-maxlength
、150 に設定された属性があります。150 文字を渡すと、$watch
トリガーされなくなりました。さらに、ctrl + x でテキスト全体を削除すると、$watch
再びトリガーされません。
入力要素
<input type="text" ng-model="company.fullName" name="companyFullName" required ng-maxlength="150" ng-input-validate />
指令
enlabApp.directive('ngInputValidate', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ctrl) {
scope.$watch(function () { return ctrl.$modelValue; }, function (value) {
console.log('test');
});
}
};
});
ng-maxlength
ディレクティブを削除すると、問題はなくなります。