小编rar*_*ude的帖子

角度点击事件未触发

我在 *ngFor 内部生成了一段代码,以及一个带有(单击)事件的跨度,我无法弄清楚为什么当我单击它时它不会触发。它不会在控制台中打印任何内容。

这可能是因为 ngFor 或 ngIf 吗?我已经尝试了所有我能想到的...

我的模板如下所示(相关部分):

<tbody>
  <ng-container *ngIf="matches">
    <tr *ngFor="let meci of matches">
      <td>{{ meci.id }}</td>
      <td>{{ meci.echipa1 }}</td>
      <td>{{ meci.echipa2 }}</td>
      <td>{{ meci.tip }}</td>
      <td>{{ meci.pretBilet }}</td>
      <td>{{ meci.nrLocuri }}</td>
      <td>{{ meci.data }}</td>
      <td class="ui center aligned">
        <span class="fas fa-trash red icon"></span>
        <span class="fas fa-edit teal icon" (click)="edit(meci)"></span>
      </td>
    </tr>
  </ng-container>
</tbody>
Run Code Online (Sandbox Code Playgroud)

组件是这样的:

export class MatchesComponent implements OnInit {
  matches: Meci[];

  constructor(private service: MatchesService, private modalService: SuiModalService) { }

  ngOnInit() {
    this.service.getAll().subscribe(matches => this.matches = …
Run Code Online (Sandbox Code Playgroud)

events click onclick angular

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

angular ×1

click ×1

events ×1

onclick ×1