<ul> <li *ngFor="let i of items"> <p>{{i.name}}</p> <button mat-button *ngIf="func();" (click)="editMessage()">edit</button> </li> </ul>
If you push a button outside the loop, only the editMessage () function is triggered. Inside - 0 reactions
component:
import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-chat', templateUrl: './chat.component.html', styleUrls: ['./chat.component.scss'] }) export class ChatComponent implements OnInit { func() { return true; } editMessage() { console.log('asd'); } constructor() { } ngOnInit() { } }