how can I dynamically generate ionic components?

0

Let's say if I have a text and input field a 5 will generate 5 buttons or if I enter a 7 then 7 buttons will be generated

    
asked by ctrl_alt_del 14.03.2018 в 04:57
source

1 answer

0

This is not a unique issue of Ionic, what you really plan is to play with the DOM of the page rendered by Ionic, I think that in this sense there may be several ways to do it, but I will limit myself to the next option that I have It happens and the best is the most practical, is that you create a list with the data of the button and then in the view using * ngFor print as many buttons as the list has. For example:

<div *ngFor="let item of botones">
    <button (click)="accion(item.accion)">{{item.nombre}}</button>
</div>

If the list starts empty in principle there would be no buttons in the window. As the list grows they would appear.

    
answered by 14.03.2018 в 11:02