2017-10-10 18 views
0

드롭 다운이있는 구성 요소가 있으며 현재 여러 옵션이 반환됩니다. '기타'옵션을 선택하면 div가 이고이 표시되는 기능을 추가하고 싶습니다. 나는 '기타'의 경우 수표를 쓰는 방법을 모르겠습니다. 여기 드롭 다운 옵션을 기반으로 div 표시

지금까지 코드 :

<div class="p-2 col"> 
 
    <select class="form-control w-100" type="checkbox" formControlName="paidToId"> 
 
     <option *ngFor="let lookupItem of leHudItemInfo.availablePaidTos" [ngValue]="lookupItem.id"> 
 
     {{lookupItem.name}} 
 
     
 
     //this returns the options, but how can I add a flag for only the string of "other" 
 
     </option> 
 
    </select> 
 
    </div>
<div class="showOther" ng-show="paidToOptions=='other'"> 
 
     </div>

HTML : <div class="" ng-show="selection=='other'"> </div>

답변

1

사용 부울 변수. 사용자가 "기타"를 선택하면 변수를 true로 설정하십시오. 그런 다음 div로 표시하거나 숨기려면 값으로 사용하십시오. 그런 다음 HTML에서

var otherOption = true; //set the value using the dropdown 

: 당신이 Angular2 +를 사용하는 경우 그런데

<div class="showOther" [hidden]={!otherOption}></div> 

, 당신은 ng-show을 사용할 수 없습니다. 해당 값은 [hidden] 또는 *ngIf이 될 수 있습니다.

+0

고마워요! 그리고 angular2에 대한 의견을 주셔서 감사합니다 :) 저는 아직 그것에 익숙하지 않습니다! – cdb