In the stocking table, I wanted to can show in a column the amount of playlists that media has. But unfortunately I do not understand how to do it, I already pulled the data from the playlists to make the association.
Component:
@Input('table-data')
public tableData: MediaModel[] = [];
@Input('table-data2')
public tableDataPl: PlaylistModel[] = [];
public data2Render: MediaModel[] = [];
public data2RenderPl: PlaylistModel[] = [];
ngOnChanges(changes: SimpleChanges) {
if (changes['tableData']) {
if (!changes['tableData'].firstChange) {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
dtInstance.destroy();
this.data2Render = changes['tableData'].currentValue;
this.dtTrigger.next();
});
}
}
if (changes['tableDataPl']) {
if (!changes['tableDataPl'].firstChange) {
console.log(this.tableDataPl.map(x => x.itens));
}
}
}
Console.log:
html:
<thead><trrole="row">
<td>Nome da Mídia</td>
<td>Tipo de Mídia</td>
<td>Ações</td>
<td>PlayList Quantidade</td>
</tr>
</thead>
<tbody>
<tr *ngFor="let media of data2Render; let i = index">
<td>{{ media.filename }}</td>
<td>{{ getMediaType(media.file_type) }}</td>
<td>??????????</td>
</tr>
</tbody>