[英]How can i pass object one component from another component in angular?
我有兩個組件DialogOverviewExample和DialogOverviewExampleDialog。 我在DialogOverviewExample中有“元素”對象,我想將此元素傳遞給DialogOverviewExampleDialog,我該如何傳遞它
DialogOverviewExample組件中的以下對象存儲
Element = [
{position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'},
{position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'},
{position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'},
{position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}
];
我希望將其打印在DialogOverviewExample組件上
檢查上面的鏈接以獲取我的組件代碼。幫助我
在您的openDialog
函數上,不是只是將Element
傳遞給data
嗎?
data: this.Element
還是我在您的問題中遺漏了一些細節?
如果您還希望傳遞代碼中包含的其他詳細信息,它將類似於
data: { element: this.Element, name: this.name, animal: this.animal }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.