1

I developed an application with angular 4 for security reason and changing the template without compiling I am trying to find a way can change HTML and application use that. somehow I need to read HTML template files from an external folder and use that. I tried to find a way, but unfortunately I could not get a direct answer I hope here I can found out is it any solution for that or not?

what I did are:

https://github.com/lacolaco/ng-dynamic

Load Angular2 template from external URL

Equivalent of $compile in Angular 2

Angular 4 Template Binding with ES6 Template String

Dynamically load HTML template in angular2

How to bind raw html in Angular2

hesam
  • 13
  • 1
  • 8

1 Answers1

1

Previously Angular were shipping angular-compiler in build (bundle js) for security reason they removed angular-compiler from bundle and reason is obvious that angular compiles code on build and there is no need to ship compiler. It creates extra overhead on your production site and also creates heavier bundle. So the answer is no. You cannot inject template from external source. Why not create a component and use condition to show your external html in this way?

Sandip Jaiswal
  • 3,428
  • 2
  • 13
  • 15
  • One of the reason is design part I need to give my code to 3th party to change the design. I was thinking If I can put templates in some where else to change that and they are some individual html files – hesam Dec 21 '17 at 15:15
  • You can inject static html. But angular will not parse that HTML. – Sandip Jaiswal Dec 21 '17 at 18:08
  • could you please explain how can I inject HTML from an external folder? – hesam Dec 22 '17 at 10:30
  • use plain javascript code for this. Just add a div with id. put html in that id. May be angular will tell that it is unsafe. Let me know if you stuck with unsafe. – Sandip Jaiswal Dec 22 '17 at 10:59