如何隐藏Angular2中的数据?

时间:2017-06-19 16:32:46

标签: html typescript angular2-template

在我的页面中,我有三个标签,在我的第三个标签中,我使用了ng-select标签。我想只显示1.ng-select标签和其他标签,即2.和3.应该隐藏,直到我选择1.tag中的数据。这是参考图片Click Here To Display The Image这里是我的代码

<ng-select [options]="options" class='filterDropDown' placeholder="Choose campaigns" [allowClear]="false" [multiple]='false' name="selectedCampaigns" style="width: 92%;margin-left: 10px;">
                    </ng-select> <br/>
                    <ng-select [options]="options" class='filterDropDown' placeholder="Choose campaigns" [allowClear]="false" [multiple]='true' name="selectedCampaigns" style="width: 92%;margin-left: 10px;" [hidden]="selectedCampaigns">
                    </ng-select>
                    <ng-select [options]="options" class='filterDropDown' placeholder="Choose campaigns" [allowClear]="false" [multiple]='true' name="selectedCampaigns" style="width: 92%;margin-left: 10px;" [hidden]="selectedCampaigns">
                    </ng-select>
                    <button class="btn submitLogo" style="margin-top:15px;" (click)="compare()">Compare</button>

1 个答案:

答案 0 :(得分:2)

我会使用([ngModel])*ngIf来执行此操作。

<ng-select ([ngModel])=tab1 </ng-select>
<ng-select ([ngModel])=tab2 *ngIf="tab1" </ng-select>
<ng-select ([ngModel])=tab3 *ngIf="tab1" </ng-select>

类似的东西。