验证值必须要在【0.01-100】之间,而且最多是2位小数
<md-input-container flex=""> <label>费率</label> <input type="number" name="fee" ng-model="config.fee" required="" pattern="^(0|([1-9]\d)|(100))(\.\d{0,2})?$"/> <div ng-messages="form.fee.$error"> <div ng-message="required">费率必须填写.</div> <div ng-message="pattern">取值区间是[0.01,100]。最多2为小数</div> </div> </md-input-container>
验证输入值必须是0和正整数
<md-input-container flex=""> <label>奖励</label> <input type="text" name="reward" ng-model="config.reward" pattern="^[0-9]\d*$" required=""/> <div ng-messages="form.reward.$error"> <div ng-message="required">奖励必须填写.</div> <div ng-message="pattern">必须是0和正整数.</div> </div> </md-input-container>
验证输入值的范围
<md-input-container flex="col-3"> <label>让利</label> <input type="number" max='50' min="0" name="maxRedpacket" ng-model="config.maxRedpacket" required=""/> <div ng-messages="form.maxRedpacket.$error"> <div ng-message="required">让利必须填写.</div> <div ng-message="min">取值区间是[0,50].</div> <div ng-message="max">取值区间是[0,50].</div> </div> </md-input-container>
验证输入值的范围,限输入0和小于等于100正数,支持小数点后2位
<md-input-container flex="col-11"> <label>费率(%)</label> <input type="text" ng-model="ctrl.detail2.unlockFeeRate" required="" pattern="^((([1-9][\d]{0,1})(\.[0-9]{1,2})?)|(0\.[0-9]{1,2})|(0|100|100.0|100.00))$" name="unlockFeeRate" /> <div ng-messages="modalForm.unlockFeeRate.$error"> <div ng-message="required">费率必须填写.</div> <div ng-message="pattern">限输入0和小于等于100正数,支持小数点后2位.</div> </div> </md-input-container>
验证输入的只能是数字和.组成
<md-input-container flex=""> <label>version</label> <input name="versionNo" ng-model="detail.versionNo" md-maxlength="10" ng-disabled="act=='edit'" required="" pattern="^[0-9.]{1,10}$" /> <div ng-messages="form.versionNo.$error"> <div ng-message="required">version必须填写.</div> <div ng-message="md-maxlength">最长是10个字符</div> <div ng-message="pattern">version是由数字和.组成.</div> </div> </md-input-container>
验证输入密码长度8-25,包含数字、字母、特殊字符其中的两种
<md-input-container flex=""> <label>密码</label> <input name="password" type="password" ng-model="myPwd.password" pattern="^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{8,25}$" required=""/> <div ng-messages="form.password.$error"> <div ng-message="required">密码必须填写.</div> <div ng-message="pattern">密码长是8-25个字符,必须包含数字、字母、特殊字符其中的两种</div> </div> </md-input-container>
$stateParams
注入$stateParams模块后,其实$stateParams就是一个对象,这个对象其实就是获取传递的参数。
如果配置路由时
//url为:/user?id&name //浏览时的url为: /user?id=1&name=lihao //那么当前页面里面控制器的$stateParams对象的值就是:{id:1,name:lihao}