Issue
I have a datatable with a button at each row. This button works
<button mat-raised-button color="primary" (click)="action(car.id)">Action</button>
I'm trying to create a button that call action(car.id) for all the rows of the datatable, so for all the car.id
<button>
<div *ngFor='let cars of car'>
<span (click)='this.action(cars.id)'>Action</span>
</div>
</button>
The button returns just ONE od the ids I tried to modify it by changing the location of the *ngFor but it stills not working. If I put the *ngFor in the button tag, it creates multiple buttons that works, but I just need one button to click on it
Solution
Inside your component ts file
public actionForAll(){
this.cars.forEach((car) => {
this.action(car.id)
});
}
Inside your component html file
<button mat-raised-button color="primary" (click)="actionForAll()">Action</button>
Answered By - Panagiotis Bougioukos
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.