0
I create a table dynamically (ngFor), as returned from a list retrieved from the database (via API).
The table displays item information and when the item has attachment(s), in the item row a command capable of getting to the server is created to bring the attachment list of that item.
This "behind the scenes" command is a Observable that waits for the return of the list of attachments to display on the screen.
My problem: for each item that has an attachment, when creating the HTML component associated with the Observable, I am creating several instances of that same Observable, if I call the command to bring the relation of attachments, all observables receive the retrieved information.
Here is a minimum code for example (business issues cannot display the source in full) (Edited: click on the link to see an example code)
<table>
<thead>
<th>Id</th>
<th>Item</th>
<th>Anexo</th>
</thead>
<tbody *ngFor="let item of listItens">
<tr>
<td>{{ item.Id }}</td>
<td>{{ item.Descricao }}</td>
<td><a *ngIf="item.PossuiAnexo"/></td> //somente crio o comando se possui anexo
</tr>
<tr *ngIf="item.PossuiAnexo">Aqui tem um componente associado a um Observable que dá get no servidor e recupera a lista dos anexos se link for "clicado" </tr>
</tbody>
</table>
Print of requests. Each of them corresponds to the "observable" of each item that contains attachment. I need to recover the data only in the observable of the item whose command was triggered.
put your code
– Eduardo Vargas
I had included a code here but disappeared. I will try to include again
– Lorena Adrian
I want to point out that there is no code error, it works. My problem is that when I create the <tr> that contains the component that will display the Observable output, all the items that are attached to it receive the result, not only in the item whose command was triggered.
– Lorena Adrian
I think if you posted your TS with the codes pertaining to the issue, it would be easier to understand.
– LeAndrade
I will try to create a Jsfiddler to better compose the question
– Lorena Adrian