I have this problem: I have a table that displays some cars and Edit/Delete buttons; I want every table row to be a car component. Instead of
<tr *ngFor="let car of filteredCars">
<td> {{car.Brand }}
..
<td> <button> Edit </button> </td>
<td> <button> Delete </button> </td>
</tr>
I need to display the car properties using a car component. So I created my component as following:
import { Component, Input } from '@angular/core';
@Component({
selector: 'car-component',
template: `
<td> {{Brand}} </td>
<td> {{Model}} </td>
<td> {{Power}} </td>
`
})
export class CarComponent {
@Input() CarId: number;
@Input() Brand: string;
@Input() Model: string;
@Input() Power: string;
}
The problem is when I try to
<tr *ngFor="let car of filteredCars">
<car-component [CarId]="car.CarId" [Brand]="car.Brand" [Model]="car.Model"
[Power]="car.Power">
</car-component>
//buttons
</tr>
The content of the car component is displayed in the first data cell of the table row:

I understand that he takes the whole car component as the first , the problem is I can't manage to achieve the solution. I tried: using templates / directive.