Angular 如何喜欢离子卡列表中的特定卡

Angular 如何喜欢离子卡列表中的特定卡,angular,ionic-framework,Angular,Ionic Framework,如何对卡片列表中的特定卡片执行“相似”操作 .html <ion-content> <ion-card *ngFor="let content of contents"> <ion-item> <ion-avatar item-start> <img src="img/marty-avatar.png"> </ion-avatar> <h2>Marty McFly</h

如何对卡片列表中的特定卡片执行“相似”操作

.html

<ion-content>
<ion-card *ngFor="let content of contents">

<ion-item>
    <ion-avatar item-start>
      <img src="img/marty-avatar.png">
    </ion-avatar>
    <h2>Marty McFly</h2>
    <p>November 5, 1955</p>
  </ion-item>

  <img src="img/advance-card-bttf.png">

  <ion-card-content>
    <p>Wait a minute. Wait a minute, Doc. Uhhh... Are you telling me that you built a time machine... out of a DeLorean?! Whoa. This is heavy.</p>
  </ion-card-content>

  <ion-row>
    <ion-col>
      <button ion-button icon-left clear small>
        <ion-icon name="thumbs-up"></ion-icon>
        <div>Likes</div>
      </button>
    </ion-col>
    <ion-col>
      <button ion-button icon-left clear small>
        <ion-icon name="text"></ion-icon>
        <div>4 Comments</div>
      </button>
    </ion-col>
    <ion-col center text-center>
      <ion-note>
        11h ago
      </ion-note>
    </ion-col>
  </ion-row>
</ion-card>
</ion-content>

马蒂·麦克弗利
1955年11月5日

等一下。等等,医生。嗯。。。你是说你造了一台时间机器。。。从德洛林出来?!哇。这个很重

喜欢 4评论 11小时前

由于数组内容包含多个项目,因此生成的卡片不止一个,因此我想从生成的卡片列表中选择一个特定的卡片。如何操作?

您可以注册一个事件,以
单击like按钮的
,如下所示

...
<button (click)="likeCard(content)" ion-button icon-left clear small>
    <ion-icon name="thumbs-up"></ion-icon>
    <div>Likes</div>
</button>
...
@再见

在主题/变量中设置此变量。scss

$colors:(
  ....,
  greydark:#717273,
)
查看文件:

<ion-col>
  <button icon-left ion-button clear small icon-only (click)="toggle()" color="{{colorCO}}">
    <ion-icon name="thumbs-up" ></ion-icon>
  </button>
</ion-col> 
谢谢

<ion-col>
  <button icon-left ion-button clear small icon-only (click)="toggle()" color="{{colorCO}}">
    <ion-icon name="thumbs-up" ></ion-icon>
  </button>
</ion-col> 
colorCO = 'greydark';
constructor(){}
  toggle(){
    if(this.colorCO == 'greydark'){
      this.colorCO = 'primary'
    }else{
      this.colorCO = 'greydark'
    }
  }