Complex component as a modal. Angular 2

1

How to use a complex form component (with services, injections, etc) as a modal without having to put your html in the parent component?

My structure is as follows:

src
----- app.component.ts
----- app.component.html
----- modals/
------------- modal_one.ts
------------- modal_one.html
------------- modal_other.ts
------------- modal_other.html

How do I use < modal_one > without putting it in the html of app.component?

    
asked by Islam Linarez 28.02.2017 в 20:19
source

2 answers

1

Good morning,

You can use componentFactoryResolver for it, and create and inject components dynamically from Typescript.

Also, I would advise you to use a framework designed for angle 2, since the normal version of bootstrap is based on the DOM tree and on jQuery, and it is not the same as using angular 2 since the DOM changes with every interaction of routing.

Link to the componentFactoryResolver:

  

link

Link for ng-bootstrap for Angular 2:

  

link

I hope it serves you;)

    
answered by 01.03.2017 / 11:10
source
0

I divided my component into two parts; one contains the modal itself (the parent) but loads the form in another (child component), so you do not load all the content into one. I do not know if it serves you but if you want to use manners in angular without so much problem, this should be your best solution.

    
answered by 22.03.2017 в 15:25