代码之家  ›  专栏  ›  技术社区  ›  physicsboy

基于布尔变量值独立扩展多个div

  •  0
  • physicsboy  · 技术社区  · 7 年前

    我有一份清单 mat-card

    我曾尝试分配一个简单的布尔值,但现在我发现所有的卡同时展开。。。

    这是一个 stackblitz

    1 回复  |  直到 7 年前
        1
  •  3
  •   Ploppy    7 年前

    由于您的卡是使用阵列中的ngFor指令创建的,因此扩展的数据也应存储在阵列中!

    thisExpands = [];
    

    .html

    [ngClass]="{expanded: thisExpands[x]}"
    
    (click)="thisExpands[x] = !thisExpands[x]"
    

    Demo

    推荐文章