How to position Popover correctly (Ionic3)

Asked

Viewed 88 times

0

I need to position my Popover exactly next to the button (more) you have inside each item. Whenever I click the more button, the Popover is triggered, but it is always in the same position regardless of the item I click. How can I solve this problem? Note: My Popover is a component, I even tried some css stylings, but it was unsuccessful, it keeps fixing the Popover in a single position.

<ion-list>
  <ion-item *ngFor="let item of itens">
    <ion-row>
      <ion-col col-2>
        <ion-avatar item-start>
          <img src="{{item.foto}}" *ngIf="item.foto">
          <img src="../../assets/imgs/sem_foto.png" *ngIf="!item.foto">
        </ion-avatar>
      </ion-col>
      <ion-col col-6>
        <h3>{{item.nome}}</h3>
        <p>Estoque: {{item.quantidadeTotal}}</p>
        <button ion-button outline color="primary"
                icon-only (click)="mostrarGrades(item)">
                Grades
                <ion-icon name="arrow-dropdown"></ion-icon>
        </button>
      </ion-col>
      <ion-col col-2>
        <h4>01/01/2019</h4>
        <h5 *ngIf="item.vlrVenda">R$ {{item.vlrVenda}}</h5>
      </ion-col>
      <ion-col col-1>
        <button ion-button small color="primary" clear
                (click)="popoverAcoesItem(item)">
                <ion-icon name="more"></ion-icon>
        </button>
      </ion-col>
    </ion-row>
    <div *ngIf="item.mostrar">
      <ion-row *ngFor="let grade of item.grades">
        <ion-col col-8>
          <h6>{{grade.nomeComposto}}</h6>
        </ion-col>
        <ion-col col-2>
          <h6>{{grade.quantidade}}</h6>
        </ion-col>
        <ion-col col-2>
          <button ion-button small clear color="dark"
                  (click)="detalhesItemGrade(grade)">
                  Ver tudo
          </button>
        </ion-col>
      </ion-row>
    </div>
  </ion-item>
</ion-list>

What I’ve tried to get you so far:

.popover-top-right .popover-content {
   transform: translateX(10%) !important;
   margin-top: -50px;
 }

It’s getting that way:

1st item on the list : inserir a descrição da imagem aqui

second item on the list: inserir a descrição da imagem aqui

  • 1

    Resolved as follows: <ion-col col-1>&#xA; <button ion-button small color="primary" clear&#xA; (click)="popoverAcoesItem($event)">&#xA; <ion-icon name="more"></ion-icon>&#xA; </button>&#xA; </ion-col>

  • 1

    And in ts: And in ts: popoverAcoesItem(myEvent){&#xA; this.itens = this.itens.map( data => {&#xA; this.teste = data;&#xA; })&#xA; let popover = this.popoverCtrl.create(PopoverListaItensComponent, {item: this.teste}, &#xA; {cssClass: 'popover-top-right'});&#xA; popover.present({&#xA; ev: myEvent&#xA; });&#xA; setTimeout(() => {&#xA; popover.dismiss();&#xA; }, 3000);&#xA; }

No answers

Browser other questions tagged

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