简体   繁体   中英

How to pass template from parent to child component and save context of execution?

I am trying to figure out how to pass template from parent to child component. I am using *ngtemplateOutlet for passing template itself. It works, but i cannot access initial scope of data.

Here is a small stackBlitz to show what i am talking about: demo code

Question is: why 'line' variable is not passed to clicked(line) method of parent component?

i think you have and error in your alert method, change it like this:

public clicked(line){
   alert('Line: ' + line);
}

it is showing the name now

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