根据从2个下拉框中的选择显示隐藏DIV

时间:2019-06-13 04:00:35

标签: javascript dart angular-dart

我有2个选择选项下拉框。我的网页中加载了多个DIV(这些DIV将在运行时动态加载),我想根据下拉框中的选择来过滤这些DIV。

 <label style="alignment: center" for="countries">Country
        <select class="form-control" id="countries" *ngIf="sCountries.length > 0" [ngModel]="0" (ngModelChange)="changeOrder($event)">
            <option value="0">All</option>
            <option *ngFor="let country of sCountries" value="{{country['Id']}}">{{country['Name']}}</option>
        </select>
    </label>

    <label style="alignment: center" for="regions">Regions
        <select class="form-control" id="regions" *ngIf="sCountries.length > 0">
            <option value="0">All</option>
            <option *ngFor="let region of sRegions" value="{{region['Id']}}">{{region['Name']}}</option>
        </select>
    </label>

我的DIV就是这样

<div *ngIf="viewModel != null" class="{{viewModel.countryId}} 
{{viewModel.regionId}}"> 

   some xyz text contents 
</div>

当我从“选择选项”中选择“国家/地区”时,代码应过滤所有具有所选CountryId的DIV。

然后,当我选择区域时,代码应根据regionId过滤该特定国家/地区的所有区域。

任何人都可以帮助我解决此问题。这里的挑战是DIV将动态加载。当选择全部时,我们必须显示所有DIV

0 个答案:

没有答案
相关问题