AngularJS leaves comments in HTML: is it possible to remove them?

This comment is a result of the element transclusion performed by ngRepeat. Looks like it’s been happening nearly since the dawn of time (in angular terms) and will be created whenever a directive asks for element transclusion.

While you certainly could wipe it out with direct HTML manipulation, it’s not a safe thing to do. Having read through the source, it suggests this comment is needed to continue compiling your HTML once the original ngRepeat element is removed. Additionally, in v1.2.0, ngRepeat adds more comments that are used to determine where repeated elements are placed.

To summarise:

  • Angular doesn’t let you remove this
  • You could do it manually but you would most likely break angular
  • To reiterate the comments, it seems a strange request to remove this comment in the first place – depending on your reasoning for doing this there may be better options for what you want to achieve.

Leave a Comment