Entonces, básicamente tengo un cuadro de texto y un botón de carga de archivos. Lo que quiero cuando el usuario ingresa un número entero en el cuadro de texto, por ejemplo: 10, luego quiero mostrar el botón de carga de archivos 10 veces.
Aquí hay una demostración de trabajo, espero que sea útil para usted.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> function AppendRow(e) { var val = e.value; if (val !== "") { var html =''; for (var i = 0; i < val; i++) { html +='<input type="file" id="file">'; } $("#append").empty().append(html); } } </script> </head> <body> <input type="text" id="input1" onkeyup="AppendRow(this)"/> <div id="append"> <div> </body> </html><!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").keyup(function(){ var val = $(this).val(); if (val !== "") { var html; for (var i = 0; i < val; i++) { html = '<input type="file" id="file">'; $("#append").append(html); } } }); }); </script> </head> <body> <input type="text" id="input" /> <div id="append"> </div> </body> </html>
Por favor use el siguiente código
<input [(ngModel)]="count" /> <div *ngFor="let item of [].constructor(count); "> <input type='file'> </div>