Angular 2:如何让*ngIf使用包含它的*ngFor数组中的值?

To *_* Be 0 typescript ionic2 angular

我是角度2和离子的新手,所以我会尽量缩短它:

 <ion-card class="acc-page-card" *ngFor="let account of accounts">
   <ion-card-content>
    <!-- Add card content here! -->
    <ion-item (click)="GoTo('AccountPage')">
        <div class="acc-img" item-left>
            <img src="{{account.img}}" alt="">
        </div>
        <div class="acc-details">
            <span class="name">{{account.title}}</span>
            <span class="title">{{account.link}}</span>
        </div>
        <div class="acc-icons" item-right>
            <i *ngIf="valueFromArray" class="icomoon-Add-user-icon"></i>
            <i *ngIf="valueFromArray" class="icomoon-Favorites-icon"></i>
        </div>
    </ion-item>
  </ion-card-content>

</ion-card>
Run Code Online (Sandbox Code Playgroud)

其中'valueFromArray'是我想要从数组得到的值我循环尝试:

<i *ngIf="{{account.isFriend}}" class="icomoon-Add-user-icon active-icon"></i>
Run Code Online (Sandbox Code Playgroud)

这是错的.所以,如何使用数组中的值我在这样的情况下循环?对不起,我的英语不好 .

Dun*_*can 5

你可以像访问任何其他变量一样访问它:

<i *ngIf="account.isFriend" class="icomoon-Add-user-icon active-icon"></i>
Run Code Online (Sandbox Code Playgroud)

img标签的另外几行应该是:

        <img [src]="account.img" alt="">
Run Code Online (Sandbox Code Playgroud)

不要在{{...}}内部属性中使用插值,只需在内容文本中使用.对于属性值,src您应该使用输入属性绑定[attribute]=value