單獨判斷 : if (!$scope.form1.$error.requirepaycode)
強制判斷 : $scope.form1.報件單號.$validate(); (考慮有些情況不會自動觸發函數)
.directive("requirepaycode", function () {
return {
restrict: 'A',
require: "ngModel",
link: function (scope, element, attributes, ngModel) {
ngModel.$validators.requirepaycode = function (modelValue, viewValue) {
return !scope.selectingPayCode() || (modelValue != null && modelValue != "");
}
}
};
})
<input requirepaycode name="報件單號" entertab ui-mask="X999999999999" model-view-value="true" class='form-control' ng-focus="focusPayCode()" ng-disabled="!newmode && !editmode" ng-model='selectData["報件單號"]'><span style='color:red' ng-show="form1['報件單號'].$error.requirepaycode">*</span>
沒有留言:
張貼留言