How to copy an html block when you click a button in Angular?

Asked

Viewed 274 times

2

I am developing an Ionic/angular application with a firestore BD up to there everything well. I’d like to do this post link I can inject the code via "ng-template" but I don’t know how to do it to repeat every time I click a button.

tela da lista Gostaria de clicar aqui e duplicar o codigo acima

adicionarOutroItem(){
// ??????
}
<ion-header>
  <ion-navbar>
    <ion-title>addItem</ion-title>
  </ion-navbar>
</ion-header>


<ion-content padding>
  <table>
    <tr *ngIf="editar == true">
      <td>Nome da Lista: </td>
      <td><input class="texto3"></td>
    </tr>


    <tr>
      <td>Nome:</td>
      <td><input class="texto3"  [(ngModel)]="nome_item"> </td>
    </tr>

    <tr>
      <td>Quantidade:</td>
      <td>
        <button ion-button class="botaoLista" (click)="diminuirQtd()">-</button> 
        <input type="text" class="texto2" value="{{qtd}}"/> 
        <button ion-button class="botaoLista" (click)="aumentarQtd()">+</button>
      </td>
    </tr>

    <tr>
      <td style="float: right;">Observação:</td>
      <td><textarea [(ngModel)]="obs" rows="10" cols="30" style="margin:2% 0%"></textarea></td>
    </tr>
  </table>
  <button ion-button full color="secondary" (click)="adicionarOutroItem()">Adicionar outro Item</button>
  <br /><br /><br />
  <button ion-button full style="margin-bottom: 3%;" (click)="addItem()">Salvar</button>
  <button ion-button full color="danger" (click)="removeItem()">Deletar</button>

</ion-content>

  • Add the code to the question and not just screenshots.

1 answer

2

  • 1

    Our such a simple solution and I didn’t think of it... thanks I’ll try to do

Browser other questions tagged

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