angular2 ngif不工作

时间:2017-11-08 16:20:11

标签: angular typescript angular2-directives angularjs-ng-if

我的HTML中有一个div,我想在上传文件时显示它。 它是一个简单的*ngIf但不知何故它不起作用:(

HTML

<div  
  *ngIf="loading" 
  style="width: 100%;height: 100%;
  position: fixed;top: 0;left: 0;background-color: darkgray;opacity: 
  0.7;z-index: 9999">
</div>

<button type="button" (click)="upload('#hqdl','vidhq')">
  upload
</button>

TS

upload(obj: string,url: string) {
    this.loadning = true;
    let fileCount: number = inputEl.files.length;
    let formData = new FormData();
    if (fileCount > 0) { 
        formData.append('data', inputEl.files.item(0));
        this.http.post(URL+url, formData).map((data : Response)=>data.json()).subscribe(
         data =>{
             if(data.success){
                 alert('OK');
                 this.loadning = false;
                }
             else{
                 alert('ERR');
                 this.loadning = false;
                }
            }
        );
    };
}

0 个答案:

没有答案