Show table only if you have widgets at angular 2+

Asked

Viewed 99 times

0

I have the following table:

    <table class="table table-bordered">
  <thead>
    <tr>
      <td>Nome</td>
      <td>Email</td>
      <td>Data</td>
      <td>Status</td>
      <td width=275 align="center">Ação</td>
    </tr>
  </thead>
  <tbody>
     <tr *ngFor="let ticket of tickets">
        <td>{{ticket.nome}}</td>
        <td>{{ticket.email}}</td>
        <td>{{ticket.data | date:'dd/mM/yyyy'}}</td>
        <td *ngIf="ticket.status == 1">Aberto</td>
        <td *ngIf="ticket.status == 2">Em Andamento</td>
        <td *ngIf="ticket.status == 3">Fechado</td>
        <td width=275>
            <a class="btn btn-info" routerLink="/show/{{ticket.id}}">Detalhes</a>
            <a class="btn btn-success" routerLink="/edit/{{ticket.id}}">Editar</a>
            <a class="btn btn-danger" (click)="deleteTickets(ticket.id)">Deletar</a>
        </td>
     </tr>

  </tbody>

</table>

I tried something like:

 <div class="col-xs-12" *ngIf="tickets.length === 0">
        <p>
          Não há tickets! Comece por <a [routerLink]="['/add']">aqui</a> !
        </p>

      </div>

    <div class="col-xs-12 table-responsive" *ngIf="tickets.length > 0">

This way it hides when there are no registered tickets, but does not show the message from <p> and when I click "Delete Ticket", I have to refresh the page to refresh. How can I fix this?

  • if you use the ngIf with 2 = doesn’t work?

  • *ngIf="tickets.length == 0"

  • does not appear the message I put in <p>, and when I click to delete the ticket I have to refresh, same thing with 3 ===

  • 1

    @Leticia I took a test in stackblitz.with and it works.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.