2016-09-19 62 views
0

我想传递孩子模态到我的父函数。我已经使用这个Modal传递孩子ID到父函数角2

app.html

<div class="head"><button class="headbtn" (click)="Popup(modal)">Add</button></div> 
<div> 
    <div class="centerDiv text-center" *ngFor="let hero of list"> 
     <div> 
     <button class="glyphicon glyphicon-trash operation"></button> 
     <button class="glyphicon glyphicon-pencil operation" (click)="Popup(modal)"></button> 
     </div> 
     <div><h4>{{hero.Name}}</h4></div> 
    </div> 
</div> 
<custom-modal></custom-modal> 

customModal.html

<modal #modal> <---- this Modal 
<modal-header [show-close]="true"> 
    <h4 class="modal-title">I'm a modal!</h4> 
</modal-header> 
<modal-body> 
    Hello World! 
</modal-body> 
<modal-footer [show-default-buttons]="true"></modal-footer> 

app.component.ts

export class AppComponent { 

    list = [{ "Name": "App 1" }]; 

    Popup(modal) { <--- I am getting this modal undefined. 
     debugger; 
     modal.open(); 
    } 
} 

我怎样才能做到这一点?

回答