2016-08-03 5 views
0

2つの入力フィールド(入力フィールド1 &入力フィールド2)があり、入力フィールド1のオプションの1つを選択すると、入力フィールド2のオプションには表示されません。それを行う?次の入力フィールドで選択したオプションを表示しないようにするにはどうすればよいですか?

input field 1 
<input type="text" ng-model="type1" uib-typeahead="value for value in gettype($viewValue)" > 

input field 2 
<input type="text" ng-model="type2" uib-typeahead="value for value in gettype($viewValue)"> 

$scope.gettype = function(val) { 
return $http.get('api', { 
    params: { 
    type: val, 
    sensor: false 
    } 
}).then(function(response){ 
    return response.data.type; 
}); 
}; 

これは何イム計画を行うために同じくらい私はあなたがNG-ブラーオプション

を使用することができます

+0

あなたの[オートコンプリート](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete)属性を使用して試みることができます2フィールド。 –

+0

@MarioAlexandroSantini thxは素早く対応します。私がui.bootstrap.typeahead –

+0

@Aswincjを使用して他のユーザーがすでに尋ねられているように、あなたが問題のあるコードサンプルを提供してくれれば、もっと簡単にヘルプを見つけることができます。 –

答えて

1

を望んでいたように、入力フィールドを繰り返しNGリピートを作成することであるだけで、サンプルコードですあなたのデータとしてautofille_data考えると

我々はNG-ぼかし上の関数を呼び出すことができ

$scope.remode(autofill_data){ 
var index=autofill_data.indexOf($scope.input_val1); 
autofill_data.splice(index, 1); 
} 

$ scope.input_val1は入力フィールド1の値です

0

テキストボックスを作成するための繰り返しです。そのあとで配列から を選択すると、選択された値を削除する必要があります。例えば:

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. 
関連する問題