javascript - How add null inputs while files are uploading, and then this files set to input -


e.g. should upload 3 files. , when click "upload" should appear 3 input. , when files finished upload write input. add file in loop. , while files uploading user should see preloader

onsubmit(e: any) { this.alertservice.clearmessage();  (let = 0; < this.files.length; i++) {   this.fileuploadservice.upload(this.files).subscribe(data => {     if (!data) {       this.alertservice.error("select files");     }     else {       this.newrow.push(" ");       this.fileslist.push(data);       this.alertservice.success("file url is: " + data.url);     }   }, error => {     this.alertservice.error(error._body);   }); } 

and html

<tr *ngfor="let file of fileslist; let i=index" >       <td><input class="form-control input-sm" *ngif="file.url" value="{{ file.url}}" /></td>       <td>{{ file.size/1024 | round }} kb</td>       <td>{{ file.modified * 1000 | date:'mm-dd-yyyy' }} </td>        <td>         <img *ngif="deleting == i" src="data:image/gif;"/>         <a *ngif="deleting !== i"  class="glyphicon glyphicon-trash" (click)="onremove(i)"></a>       </td>     </tr> 

solved it.

onsubmit(e: any) { this.alertservice.clearmessage();  (let = 0; < this.files.length; i++) { // im getting empty fields way , know number of uploaded files   let newitemid = this.fileslist.push(this.fake) - 1;     this.fileuploadservice.upload(this.files).subscribe(data => {     if (!data) {       this.alertservice.error("select files");     }     else {       //  push data in array of getting lenght       this.fileslist[newitemid] = data;       this.alertservice.success("file url is: " + data.url);     }   }, error => {     this.alertservice.error(error._body);   }); } 

}


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -