AngularJS ng-min ng-max

前端之家收集整理的这篇文章主要介绍了AngularJS ng-min ng-max前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/**
*name:public.Echart
*date:2017-5-24
*/
functionisEmpty(value){
returnangular.isUndefined(value)||value===''||value===null||value!==value;
}
define(['publicMax'],function(){
angular.module('public.Max',[]).directive('ngMax',function($http,$window){
return{
restrict:'A',require:'ngModel',link:function(scope,elem,attr,ctrl){
scope.$watch(attr.ngMax,function(){
ctrl.$setViewValue(ctrl.$viewValue);
});
varmaxValidator=function(value){
varmax=scope.$eval(attr.ngMax)||Infinity;
if(!isEmpty(value)&&value>=max){
ctrl.$setValidity('ngMax',false);
returnundefined;
}else{
ctrl.$setValidity('ngMax',true);
returnvalue;
}
};
ctrl.$parsers.push(maxValidator);
ctrl.$formatters.push(maxValidator);
}
};
})
});
/**
*name:public.Echart
*date:2017-5-24
*/
functionisEmpty(value){
returnangular.isUndefined(value)||value===''||value===null||value!==value;
}
define(['publicMin'],function(){
angular.module('public.Min',[]).directive('ngMin',ctrl){
scope.$watch(attr.ngMin,function(){
ctrl.$setViewValue(ctrl.$viewValue);
});
varminValidator=function(value){
varmin=scope.$eval(attr.ngMin)||0;
if(!isEmpty(value)&&value<=min){
ctrl.$setValidity('ngMin',false);
returnundefined;
}else{
ctrl.$setValidity('ngMin',true);
returnvalue;
}
};

ctrl.$parsers.push(minValidator);
ctrl.$formatters.push(minValidator);
}
};
})
});
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.everymanLow_edit.$dirty&&myForm3.everymanLow_edit.$invalid&&!everymanLow_edit]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>普通柜员低限</label>
<divclass="col-xs-8">
<inputclass="form-control"placeholder="请输入数字"id="everymanLow_edit"name="everymanLow_edit"ng-model="everymanLow_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.everymanLow_edit.$dirty&&myForm3.everymanLow_edit.$invalid&&!everymanLow_edit">请输入普通柜员低限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.everymanHigh_edit.$dirty&&myForm3.everymanHigh_edit.$invalid&&!everymanHigh_edit&&myForm3.everymanHigh_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>普通柜员高限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="everymanLow_edit"ng-max="directorHigh_edit"placeholder="请输入数字"id="everymanHigh_edit"name="everymanHigh_edit"ng-model="everymanHigh_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.everymanHigh_edit.$dirty&&myForm3.everymanHigh_edit.$invalid&&!everymanHigh_edit&&myForm3.everymanHigh_edit.$error.ngMin">请输入普通柜员高限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.directorLow_edit.$dirty&&myForm3.directorLow_edit.$invalid&&!directorLow_edit&&myForm3.directorLow_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>审批主管低限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="everymanLow_edit"ng-max="directorHigh_edit"placeholder="请输入数字"id="directorLow_edit"name="directorLow_edit"ng-model="directorLow_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.directorLow_edit.$dirty&&myForm3.directorLow_edit.$invalid&&!directorLow_edit&&myForm3.directorLow_edit.$error.ngMin">请输入审批主管低限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.directorHigh_edit.$dirty&&myForm3.directorHigh_add.$invalid&&!directorHigh_edit&&myForm3.directorHigh_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>审批主管高限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="directorLow_edit"ng-max="sectionchiefHigh_edit"placeholder="请输入数字"id="directorHigh_edit"name="directorHigh_edit"ng-model="directorHigh_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.directorHigh_edit.$dirty&&myForm3.directorHigh_edit.$invalid&&!directorHigh_edit&&myForm3.directorHigh_edit.$error.ngMin">请输入审批主管高限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.sectionchiefLow_edit.$dirty&&myForm3.sectionchiefLow_edit.$invalid&&!sectionchiefLow_edit&&myForm3.sectionchiefLow_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>审批处长低限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="directorLow_edit"ng-max="sectionchiefHigh_edit"placeholder="请输入数字"id="sectionchiefLow_edit"name="sectionchiefLow_edit"ng-model="sectionchiefLow_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.sectionchiefLow_edit.$dirty&&myForm3.sectionchiefLow_edit.$invalid&&!sectionchiefLow_edit&&myForm3.sectionchiefLow_edit.$error.ngMin">请输入审批处长低限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.sectionchiefHigh_edit.$dirty&&myForm3.sectionchiefHigh_edit.$invalid&&!sectionchiefHigh_edit&&myForm3.sectionchiefHigh_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>审批处长高限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="sectionchiefLow_edit"ng-max="topmanagerHigh_edit"placeholder="请输入数字"id="sectionchiefHigh_edit"name="sectionchiefHigh_edit"ng-model="sectionchiefHigh_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.sectionchiefHigh_edit.$dirty&&myForm3.sectionchiefHigh_edit.$invalid&&!sectionchiefHigh_edit&&myForm3.sectionchiefHigh_edit.$error.ngMin">请输入审批处长高限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.topmanagerLow_edit.$dirty&&myForm3.topmanagerLow_edit.$invalid&&!topmanagerLow_edit&&myForm3.topmanagerLow_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>审批总经理低限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="sectionchiefLow_edit"ng-max="topmanagerHigh_edit"placeholder="请输入数字"id="topmanagerLow_edit"name="topmanagerLow_edit"ng-model="topmanagerLow_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.topmanagerLow_edit.$dirty&&myForm3.topmanagerLow_add.$invalid&&!topmanagerLow_edit&&myForm3.topmanagerLow_edit.$error.ngMin">请输入审批总经理低限!</span>
</div>
</div>
</div>
<divclass='col-xs-6'>
<divclass="form-group"ng-class="{true:'red',false:''}[myForm3.topmanagerHigh_edit.$dirty&&myForm3.topmanagerHigh_edit.$invalid&&!topmanagerHigh_edit&&myForm3.topmanagerHigh_edit.$error.ngMin]">
<labelclass="col-xs-4control-label"><spanclass="red">*</span>审批总经理高限</label>
<divclass="col-xs-8">
<inputclass="form-control"ng-min="topmanagerLow_edit"placeholder="请输入数字"id="topmanagerHigh_edit"name="topmanagerHigh_edit"ng-model="topmanagerHigh_edit"type="text"value=""ng-minlength="1"ng-maxlength="20"minlength="1"maxlength="20"ng-pattern="/^\d+(\.\d+)?$/"required>
<spanclass="redshow_Notes"ng-show="myForm3.topmanagerHigh_edit.$dirty&&myForm3.topmanagerHigh_edit.$invalid&&!topmanagerHigh_edit&&myForm3.topmanagerHigh_edit.$error.ngMin">请输入审批总经理高限!</span>
</div>
</div>
</div>
原文链接:https://www.f2er.com/angularjs/146676.html

猜你在找的Angularjs相关文章