您好,这是我第一次在stackoverflow上提问.我正在开发angular2:v2.1.0(typescript-v2.0.10)中的应用程序.我使用"ng2-file-upload"进行文件上传.HTML代码如下:
<div class="container-fluid">
<h5 class="titleCenter"> File Upload </h5>
<div class="drop-zone" ng2FileDrop
[ngClass]="{'nv-file-over': hasBaseDropZoneOver, 'pointerBan': testDisablDropZone}"
(fileOver)="fileOverBase($event)"
[uploader]="uploader">
<span *ngIf="isUploaderEmpty(uploader.queue)">Drop Down box for the CSV file only...!!!</span>
<span *ngFor="let item of uploader.queue" >
<p class="row" >
<i class="fileIcon"></i>
<strong>{{ item?.file?.name }}</strong>
<a class="fileUploadRemoveButton fa fa-times-circle" (click)="item.remove()"></a>
</p>
</span>
</div>
<div [ngClass]="{'activeCheckButton': testDisablDropZone}" class="CheckboxZone" (click)="disableDropZone($event)" style="margin-top: 10px">
<span>Click here to disable the dropdown box.</span>
</div>
</div>
<button type="button" (click)="test($event)">click</button>
Run Code Online (Sandbox Code Playgroud)
这里当我点击带有'CheckboxZone'类的div时,它会调用函数'disableDropZone($ event)',但之后它也会调用函数'idUploadEmpty()'.按钮的情况相同也点击.组件的代码如下:
const URL = 'https://evening-anchorage-3159.herokuapp.com/api/';
@Component({
selector: 'fileupload',
templateUrl: './fileupload.component.html',
styleUrls: ['./fileupload.component.scss'] …Run Code Online (Sandbox Code Playgroud)