简体   繁体   中英

I need to close the popup message in component.ts in angular4

In component.html i have a popup message currently the opening and closing functionality is in html but i need the close functionality in a method

   <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) will open the popup message and c('Close click') will close the popup message in Component.html but i need this close functionality in uploadfile() method Please help me this this issue

I think all you need is to pass the reference to the function ,

Template Side :

Change :

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

to

(click)="uploadfile(c)"

Component Side :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM