sdApp.directive("sdVerNumber", function(){
return{
restrict: "A",
replace: true,
template: "<input type=\"text\" ng-pattern=\"/^([1-9]+[0-9]*|[0])([.]+[0-9]{0,2}|[.])?$/\" />"
};
});
<input type="text" sd-ver-number class="sd-input-text sd-input-small" style="width:80px;" ng-model="addListData.m1" />当输入内容错误的时候,对应状态的类ng-invalid-pattern没有相应改变。而直接把整个ng-pattern写在HTML上是可以正常工作的。请问这是为什么呢?
1 回答

四季花海
TA贡献1811条经验 获得超5个赞
sdApp.directive("sdVerNumber", function(){
return{
restrict: "A",
replace: true,
template: "<input type=\"text\" ng-pattern=\"^([1-9]+[0-9]*|[0])([.]+[0-9]{0,2}|[.])?$\" />"
};
});
<input type="text" sd-ver-number class="sd-input-text sd-input-small" style="width:80px;" ng-model="addListData.m1" />
添加回答
举报
0/150
提交
取消