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

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

4 Comments

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
You can inject static html. But angular will not parse that HTML.
could you please explain how can I inject HTML from an external folder?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.