我有幾個使用篩選器搜索綁定的輸入框。所以當我刪除一個字符時,顯示結果會自動更新。 但我有很多輸入框,我不想將鼠標導航到每個輸入並手動刪除文本。Angular ng-repeat的調用輸入焦點更改
所以我所做的是有清除了所有的輸入框
function clearForm() {
$('#searchcompanyName').val('');
$('#searchbusinessLN').val('');
... and so on
這將清除出形式,但它不更新的角度搜索結果中的文本的功能。怎麼能拿角更新的內容是在輸入
.controller('srchJobOrdersCtrl', function (Jobs, socketio) {
var vm = this;
vm.search = {
date: '', companyName: '', businessLN: '',
guideName: '', guideLN: '', phoneNum: '', citizenshipNo: '',
totalPeople: '', cashChina: '', cashThailand: '', tourManNo: '', licensePlate: '',
arrvDate: '',
deptDate: '',
arrFltNo: '',
staying: '',
deptNo: '',
time: '',
cashThailand: '',
cashThailand: '',
};
Jobs.getJobsOrders()
.success(function(data) {
vm.jobOrders = data;
});
vm.clearSearch = function() {
vm.search = {
date: '', companyName: '', businessLN: '',
guideName: '', guideLN: '', phoneNum: '', citizenshipNo: '',
totalPeople: '', cashChina: '', cashThailand: '', tourManNo: '', licensePlate: '',
arrvDate: '',
deptDate: '',
arrFltNo: '',
staying: '',
deptNo: '',
time: '',
cashThailand: '',
cashThailand: '',
};
};
HTML
<label id='searchLabelT' class='searchLabel'></label>
<input type="text" class="form-control inputWidth3" placeholder="" id='searchcompanyName' ng-model='search.companyName'>
<input type="text" class="form-control inputWidth3" placeholder="" id='searchbusinessLN' ng-model='search.businessLN'>
<input type="text" class="form-control inputWidth3" placeholder="" id='searchguideName' ng-model='search.guideName'>
<input type="text" class="form-control inputWidth3" placeholder="" id='searchguideLN' ng-model='search.guideLN'>
<input type="text" class="form-control inputWidth3" placeholder="" id='searchphoneNum' ng-model='search.phoneNum'>
<tbody>
<tr ng-repeat="each in allJobsOrder.jobOrders | reverse | filter:search">
<td>{{ $index + 1 }}</td>
<td>{{ each.date }}</td>
<td>{{ each.companyName }}</td>
<td>{{ each.businessLN }}</td>
<td>{{ each.guideName }}</td>
<td>{{ each.guideLN }}</td>
<td>{{ each.phoneNum }}</td>
向我們顯示您的輸入框的HTML代碼。所以這將更好地解釋你。 –