重複用於創建文本框。 之後,您需要刪除已選擇的那些值。例如:
html code
<span"><input type="text" ng-model="x.name1"</span>
<span"><input type="text" ng-model="x.name2"</span>
<span"><input type="text" ng-model="x.name3"</span>
js code:
Suppose your suggestion values are coming from array named $scope.usStates.
now you have to remove compare both value inside x an $scope.usStates and remove the matching element from $scope.usStates. you can use index of particullar element and splice method for removing an element.
example:
$scope.usStates.splice(index, 1);
$scope.usStates = [
{ name: 'ALABAMA', abbreviation: 'AL'},
{ name: 'ALASKA', abbreviation: 'AK'},
{ name: 'AMERICAN SAMOA', abbreviation: 'AS'},
{ name: 'ARIZONA', abbreviation: 'AZ'},
{ name: 'ARKANSAS', abbreviation: 'AR'},
{ name: 'CALIFORNIA', abbreviation: 'CA'},
{ name: 'COLORADO', abbreviation: 'CO'},
{ name: 'CONNECTICUT', abbreviation: 'CT'},
{ name: 'DELAWARE', abbreviation: 'DE'},
{ name: 'DISTRICT OF COLUMBIA', abbreviation: 'DC'},
{ name: 'FEDERATED STATES OF MICRONESIA', abbreviation: 'FM'},
{ name: 'FLORIDA', abbreviation: 'FL'},
{ name: 'GEORGIA', abbreviation: 'GA'}]
Thanks.
您可以通過使用在[自動完成](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete)屬性試試2個字段。 –
@MarioAlexandroSantini thx快速響應。即時通訊使用ui.bootstrap.typeahead –
@Aswincj如其他用戶已經問過,如果您向我們提供代碼示例,那麼您將更容易找到幫助。 –