如何隐藏angular2模板中列表中的选定列表项?

时间:2017-06-19 21:13:24

标签: angular ng-hide

我正在尝试隐藏列表项目,该列表项目已被选中并添加到另一个列表但不知道应用什么,因此添加的项目不会显示在列表中。

  <div class="countries-list">
    <span class="countries-list__header">{{'GeneralOrganizationalBackgroundSurveyComponent-STEP_6_ALL_LOCATIONS' | translate}}</span>
    <ul>
        <li *ngFor="let country of filteredCountries"
            (click)="selectCountry(country, 'add')"
            class="add"
            [ngClass]="{'selectedCountry':   selectedCountry?.name == country.name && selectedCountry?.action === 'add',
                        'disabledSelection': selectedCountry?.disabledSelection && selectedCountry?.name == country.name}">
            {{ country.name }}
        </li>
    </ul>
</div>
<div class="contries-controllers">
    <a class="btn-floating btn waves-effect waves-light cyan darken-3"
       [ngClass]="{'disabled': selectedCountry === null || selectedCountry?.action === 'delete'}"
       (click)="addCountryFromForm(selectedCountry.code)">
        <i class="material-icons">add</i>
    </a>
</div>

1 个答案:

答案 0 :(得分:1)

似乎是*ngIf指令的确切用例,例如:

<li *ngIf='!selectedCountries.includes(country.code)'