0
Hi, I was wondering if someone could help me, today I have a table that receives data from a Komponent(Medias), I have another Component that is playlists, on playlists I associate the medias to a playlist.
In the medias table, I wanted can show in a column the amount of playlists that media has. But unfortunately I’m not understanding how to do, 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>
<tr role="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>
How do I capture the item from one of these columns in the array? , I’m not getting it =(
– Paulo Felipe Martins
In case I’m wanting to do the opposite, it is now grouped, I want to break this and put in one as its creation code of the array
– Paulo Felipe Martins
Puts how you receive the data and how you need the output. .
– jcebidanes