gpt4 book ai didi

javascript - AngularJS:重置功能重置表格但不清除输入字段并选择?

转载 作者:行者123 更新时间:2023-12-02 16:57:31 24 4
gpt4 key购买 nike

<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 &#163;: <input type="number" ng-init="minNum=0" class="form-control price-input" min="0" step="1000" ng-model="minNum" /></label>
<label>Max Price &#163;: <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>

这是我的 Controller :

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;
}

当我点击reset按钮时,我的表格会更新,因此currentCarTypenullrevNum 30minNum0maxNum0。但我的 input 字段以及我的 select 没有更新。我该如何解决这个问题?

最佳答案

我猜您可能陷入了这里讨论的问题: Why don't the AngularJS docs use a dot in the model directive?

输入的模型在父范围内初始化,但是一旦您在其中进行编辑,该值就会存储在子范围中,随后也从那里读取。

关于javascript - AngularJS:重置功能重置表格但不清除输入字段并选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26055595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com