我需要在angular4中的component.ts中关闭弹出消息

时间:2018-02-23 11:44:43

标签: javascript angular

在component.html中,我有一条弹出消息,当前打开和关闭功能是在html中,但我需要方法中的关闭功能

   <ng-template #content let-c="close" let-d="dismiss">
         <div class="modal-header">

          <button type="button" class="close" aria-label="Close" 
            (click)="d('Cross click')">
             <span aria-hidden="true">&times;</span>
            </button>

             <h4>Cinema Operator</h4>
                </div>
                <div class="modal-body">
                <li class="nav-item"> Import from your Excel </li>
                 </div>
                   <div class="modal-footer">

             <input type="file" accept=".xlsx" class="btn btn-
                 success"(change)="onFileChange($event)">

                <button type="file" class="btn dark btn-outline" 
                (click)="c('Close click');uploadfile()">Upload</button>
                              </div>
                        </ng-template> 
    ----------------------------------------------------
 <button class="btn btn-default" *ngIf="message" (click)="open(content)">Add New Operator</button>

open(content)将打开弹出消息,c(&#39; Close click&#39;)将关闭Component.html中的弹出消息,但我需要uploadfile()方法中的这个关闭功能 请帮我解决这个问题

1 个答案:

答案 0 :(得分:0)

我认为你需要的只是将参考传递给函数,

模板面:

更改:

(click)="c('Close click');uploadfile()"

(click)="uploadfile(c)"

组件方:

uploadfile(c){
    ... // your code
    c('Close click');
}