Angular - transfer components from one system to another

Asked

Viewed 84 times

0

Good afternoon. I have a Component that contains some child components, I have another component containing other child components. I want to reverse the children of one for the other, but I want the children to bring their events with them.

conceptual example:

<comp1>
  <compfilhoa [prop1]="vary"(event)="eventa($event)">
  </compfilhoa>

</comp1>

<comp2>
  <compfilhob [propr2]="varx" (event)="eventb($event)">
  </compfilhob>
</comp2>

I want to put at run time the compb inside the comp1 and compa inside the comp2. I want the compb and the compa to take all their characteristics and events. What library of Angular I need to use to do this?

  • Partner, for me it got a little fuzzy the idea of this there. Could you explain in form of business rule? Bringing more into the real world so we can better assimilate the idea?

  • The components comp1 and comp2 are the same types? And the compfilhoa and compfilhob are the same types? If the answer is yes to both, I would suggest you change the object in yours. ts with each other, so the components would update in real time with the new data.

  • so... I’m making the component that would be comp 1 and 2.. I’m going to call swap-drag-drop, the idea is to drag one over the other and swap the content. I don’t know what components will be put inside them. Imagine that in one part of the screen there is a swap-drag-drop with 3 buttons and a table and in the other part I have a totally different table, when dragging one over the other, I will insert the contents. I did it using innerHTML, but then the methods stop working, if I have a button, it does nothing else

1 answer

0

If it’s the effect drag and drop angular implemented in version 7, to transfer data between components you can use Input and output, or Subject in services for component communication, another alternative is to use some library to control the state of the application, such as ngrx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.