2017-10-10 17 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

使用ブール変数ここ

はコードは今のところです。ユーザーが「other」を選択した場合は、変数を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

関連する問題