3

Angular 1.x lets you include template partials using the ngInclude directive.

Angular 2+ does not have this directive. Current suggested solutions are to create a component instead. I don't want to have to do this, because I doubt that every case of DRYing up a template are a case where you should make a new component. That's because I suspect that adding components for every de-dup of template code will create a separate problem of component clutter in my project and lots of unnecessary @Component statements around the place.

So how can you just include one template in another in Angular 2+? (Or why is it true that every case of attempted template inclusion is really a case where you should make a whole new component?)

Trindaz
  • 17,029
  • 21
  • 82
  • 111

1 Answers1

0

The truth is angular 2 does not play very well with things that manipulate the dom. That's why they deprecated ng-include with no replacement. However that said checkout this: https://www.npmjs.com/package/ng-include which kind of worked for me.

John Doe
  • 3,794
  • 9
  • 40
  • 72
  • Thanks for the link. I don't understand how this implementation of `ng-include` would work as a general solution because it requires all your templates to be available for individual download, and would delay render time by waiting for the response. – Trindaz May 25 '17 at 17:34