如何从`* ngFor`循环设置局部变量?

时间:2018-05-14 13:13:15

标签: angular

我要求在标题栏中显示一个值。但是*ngFor循环中的数据。怎么做到的?

这是我的代码:

    <h4 [ngClass]="{'drop-down' : country === countryCode }">{{countryCode}}</h4> //need to show here from under the loop
  <ul class="country-list">
        <li 
            *ngFor="let country of supportedCountries;" 
            (click)="updateCountry(country)">
            <span [hidden]="country === countryCode">{{getPropCountry(country)}} {{country}} {{countryCode}}</span> //hiding
            <ng-container *ngIf="country !== countryCode">{{getPropCountry(country)}} {{country}} {{countryCode}}</ng-container>
            </li>
</ul>

0 个答案:

没有答案