【问题标题】:Is it possible to make different click event for mat-checkbox and mat-checkbox label? [closed]是否可以为 mat-checkbox 和 mat-checkbox 标签制作不同的点击事件? [关闭]
【发布时间】:2019-03-20 05:42:49
【问题描述】:

我需要为 mat-checkbox 及其标签设置不同的点击事件。谁能帮我解决这个问题。

【问题讨论】:

    标签: angular-material2 angular7


    【解决方案1】:

    您可以执行以下操作来完成此操作。

    将您的标签文本放在span 中,并使用(click) 表示span,使用(change) 表示mat-checkbox

    <mat-checkbox (change)="SetString('CheckBox')"></mat-checkbox>
    <span style="margin-left:2%" (click)="SetString('CheckBoxTag')">Click here for tag event!</span>
    

    堆栈闪电战

    https://stackblitz.com/edit/angular-z1pgeg?embed=1&file=app/checkbox-overview-example.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-06
      • 2019-05-13
      • 1970-01-01
      • 2020-04-28
      • 2020-07-09
      • 2023-01-10
      • 2019-11-25
      • 2021-02-16
      相关资源
      最近更新 更多