2017-02-18 2 views
1

UIには2つのラジオボタンが表示され、1つはYESで、1つはNOです。ユーザーがYESラジオをクリックしてからドロップダウンを表示し、テキストボックス、ラジオボタンの切り替え中にドロップダウンとテキストボックスの値をクリアする方法。これは、テキストボックスと前の値を表示するドロップダウンの両方で、switching.pleaseが役に立ちます。角2:ラジオボタンを切り替えるときにドロップダウンとテキストボックスの値をクリアする方法

<div id="radio" class="row">Are you an existing client?</p> 

     <div class="form-check form-check-inline"> 
      <label class="form-check-label"> 
       <input type="radio" [(ngModel)]="radioValue" value="yes"/>yes 
      </label> 
     </div> 

     <div class="form-check form-check-inline"> 
       <label class="form-check-label"> 
       <input type="radio" [(ngModel)]="radioValue" value="no"/>no 
       </label> 
     </div> 
     </div> 

     <label *ngIf="radioValue == 'yes'">Select Client</label> 
      <select #select [(ngModel)]="cuurent" (change)=logDropdown(select.value) class="form-control input-group" 
       *ngIf="radioValue == 'yes'"> 
       <option *ngFor="let item of list" [value]="item.id">{{item.name}}</option> 
      </select> 

     <div class="form-group"> 
      <label *ngIf="radioValue == 'no'">Enter Client</label> 
      <input type="text" [(ngModel)]="inputsic" class="form-control input-group" *ngIf="radioValue == 'no'" /> 
     </div> 
      </div> 
+1

コードを投稿してください。 –

+0

@gunter zochbauerその異なる質問.iユーザーがredioのボタンを切り替えたときにドロップダウンの以前の値をクリアする必要があります。 –

答えて

2
<input type="radio" [(ngModel)]="radioValue" (ngModelChange)="reset()" value="yes"/>yes 
<input type="radio" [(ngModel)]="radioValue" (ngModelChange)="reset()" value="no"/>no 
reset() { 
    this.inputsic = ''; 
    this.current = null; 
} 
関連する問題