为什么角度模型不适用于输入类型编号?但在输入类型文本中起作用。html5 input type =“number”在angularjs中不适用于ng-model =“selectedItem.price”
这里是我的代码
<input type="number" step="0.01" name="price" ng-model="selectedItem.price" autocomplete="off">
这里的解决方案。在我的数据库中的数据类型是小数不串..但angularjs使其串它得到的数据之后..所以我加上“+”将其再次转换为int。
$scope.selectedItem={ item_id:"", item_name:"",supplier:"",price:"",description:"" };
<input type="number" step="0.01" name="price" ng-model="+selectedItem.price" autocomplete="off">
这是什么**步骤**? ** ng-model **中传递的值是多少? – Thangadurai
在输入元素 – Jayrex
中设置十进制格式在ng-model中传递什么值?我认为在** selectedItem.price **你的传递字符串...你可以检查ng-model的数据类型..如果你传递** selectedItem.price ==“2”**这样它不会工作。只需要传递整数值。 – Thangadurai