2017-09-12 56 views
1

我有一個服務中的元素列表,所以我需要發送名稱和其他屬性爲每個元素的模態onclick事件,我有這個代碼。謝謝 enter image description here創建動態模態角4

+0

你不能將它們作爲參數? –

回答

2

onclick該項目,將項目信息傳遞給showDialog方法。在你的對話框顯示爲傳遞的信息如下:

<h2>{{this.profileSelected}}</h2> 

<p (click)="showDialog(item)"></p> 

在你的組件創建profileSelected存儲項目點擊如下成員變量:

showDialog(item){ 
    this.profileSelected = item; 
    this.display=true; 
} 
+0

謝謝:)這麼多 –