lacolaco / angular2-component-outlet

Angular2 dynamic component outlet
33 stars 9 forks source link

Is it possible to show components with templateUrl instead of template? #20

Open Ks89 opened 8 years ago

Ks89 commented 8 years ago

Is it possible to show components with templateUrl instead of template?

Also, is it available a fully working usage-example of this lib? If not, I suggest to add it into your repository, for instance under an "example" folder.

lacolaco commented 8 years ago

I recommend you to use angular2-template-loader with webpack.

But for some reason, I intend to stop a challenge, $compile in Angular 2.

Dynamic component creation needs some tricky setup to work in AoT. In AoT platform, RuntimeCompiler is not provided. It's a big advantage to reduce application bundle size. Our way is out of the official rail. $compile is very slow, unsafe and it need the compiler in runtime. We may lose great performance of Angular 2. We'll be left behind of Angular way, in near future.

I think my goal should be solved by innerHTML and DOM APIs, without Angular...

Ks89 commented 8 years ago

Ah Ok. But, I need to solve a specific problem. I want to try to explain it. Any advice is welcome.

Suppose that I have many html files (text plus some additional tags, for instance, strong, b, br and so on...very basic...no script tags :) ) and their urls in a db. Also, I have a component with a page composed by some sections that I want to fill with those html files using angular 2. How can I include these files dynamically to show their content as html? I want to use only a single component (the skeleton of the webpage, with a fixed number of sections and so on) to fill it dynamically with html.

I know, probably I should put html texts directly inside my db. At the moment I modified an older version of your library to accept templateUrls (very simple and basic). In your opinion, How can I do this in a better and SECURE way?

Thank u. Ks89