Javascript AngularJS:reset函数重置表格,但不清除输入字段并选择?
当我点击Javascript AngularJS:reset函数重置表格,但不清除输入字段并选择?,javascript,html,angularjs,select,input,Javascript,Html,Angularjs,Select,Input,当我点击reset按钮时,我的表格会更新,因此currentCarType为null,revNum为30,minNum为0且maxNum为0。但是我的输入字段以及我的选择不会更新。我该如何解决这个问题?我想你可能会爱上这里讨论的问题: 输入的模型在父作用域上初始化,但一旦在其中编辑,值就会存储在子作用域中,并随后从子作用域中读取。hi,您可以尝试此$scope.currentCarType='';与resetType函数中的null不同,问题实际上是因为角度模型中的点问题。 <form
reset
按钮时,我的表格会更新,因此currentCarType
为null
,revNum
为30
,minNum
为0
且maxNum
为0
。但是我的输入
字段以及我的选择
不会更新。我该如何解决这个问题?我想你可能会爱上这里讨论的问题:
输入的模型在父作用域上初始化,但一旦在其中编辑,值就会存储在子作用域中,并随后从子作用域中读取。hi,您可以尝试此$scope.currentCarType='';与resetType函数中的null不同,问题实际上是因为角度模型中的点问题。
<form novalidate class="simple-form">
<label ng-hide="tab==1">Reviews Min: <input type="number" ng-init="revNum=30" class="form-control review-input" min="0" step="10" ng-model="revNum" /></label>
<label>Min Price £: <input type="number" ng-init="minNum=0" class="form-control price-input" min="0" step="1000" ng-model="minNum" /></label>
<label>Max Price £: <input type="number" ng-init="maxNum=0" class="form-control price-input" min="0" step="1000" ng-model="maxNum" /></label>
<label><select ng-model="currentCarType" style="display:block;" ng-options="key for key in carTypeObj">
<option value="">Select Type</option>
</select></label>
<label><button class="btn btn-primary " style="display:block;" ng-click="updateNumArray(revNum, minNum, maxNum); updateType(currentCarType)">Filter</button></label>
<label><button class="btn btn-primary " style="display:block;" ng-click="resetNumArray(); resetType()">reset</button></label>
</form>
carApp.controller("TableBodyCtrl", function($scope, $http){
$scope.revNum = 30;
$scope.minNum = 0;
$scope.maxNum = 0;
$scope.currentCarType = null;
$scope.resetType = function(){
$scope.currentCarType = null;
}
$scope.resetNumArray = function(){
$scope.revNum = 30;
$scope.minNum = 0;
$scope.maxNum = 0;
}