Html 句柄浮点输入交叉串列器
在angular应用程序中,我需要将范围变量绑定到浮点用户输入Html 句柄浮点输入交叉串列器,html,input,user-input,angular-ngmodel,angular-directive,Html,Input,User Input,Angular Ngmodel,Angular Directive,在angular应用程序中,我需要将范围变量绑定到浮点用户输入 <my-float ng-model="myValue" name="floatValue"></my-float> <button type="button" ng-disable="myValue.$invalid">Submit</submit> 使用html <input name=&q
<my-float ng-model="myValue" name="floatValue"></my-float>
<button type="button" ng-disable="myValue.$invalid">Submit</submit>
使用html
<input name="x" type="text" my-float ng-model="value">
<div>error:{{f.x.$invalid}}</div>
错误:{f.x.$invalid}
这里有一个我想说的是,你把myValue作为字符串,为了有效性,你可以说:
1. if ( myValue[n-2] == ',' or myValue[n-3] ==',')
split the string into two by ,
else split the string into two by .
2. check second splited part is a number and length is less than two else invalid input
3. check first part is number , If yes a valid input or else invalid
我需要限制用户只看到允许的字符。。。所以我尝试使用$formatters和$render
1. if ( myValue[n-2] == ',' or myValue[n-3] ==',')
split the string into two by ,
else split the string into two by .
2. check second splited part is a number and length is less than two else invalid input
3. check first part is number , If yes a valid input or else invalid