The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Set Properties on Dynamically Created Angular 2 Components

Set Properties on Dynamically Created Angular 2 Components

1:47
When you generate Angular 2 components, you’re still able to access the component instance to set properties and invoke methods from the component class.
Watch this lesson now
Avatar
egghead.io

When you generate Angular 2 components, you’re still able to access the component instance to set properties and invoke methods from the component class.

Avatar
St Clair

Hi,
I have a detachRow() method on the dynamically created component that detaches a newly created sibling of the container. Now, when button is clicked the detachRow() is invoked. I receive the row created by an @Input as you described, but the #container is part of the parent. So I will have to send an event that the parent can intercept with the index of the container to delete the appropriate component.

Now, the parent itself is instantiated by the router by a button. In this scenario, how can I communicate with the router-instantiated parent from the dynamically created child to send the row index of the dynamically created child so the parent can then use the index to delete the appropriate siblings from the container.

Hope this is clear. And thanks.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?