0
我應該上傳3個文件。當我點擊「上傳」時應該出現3個輸入。當文件完成上傳時,它們將寫入該輸入。 我在循環中添加文件。同時文件上傳用戶應該看到預加載如何在文件上傳時添加空輸入,然後將此文件設置爲輸入
onSubmit(e: any) {
this.alertService.clearMessage();
for (let i = 0; i < 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);
});
}
和我的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>