Is there a way to prevent Angular from creating "helper" HTML comments? For example,
<div ng-include="myTemplate"></div>
Will transform into something like
<!-- ngInclude: 'hurr-durr.html' -->
<div ng-include="myTemplate"></div>
How do I stop this? I've looked into the Angular source, and I've seen these "helpers" are generated by an unconditional document.createComment inside almost every directive, so I guess there's no way to stop them all at once by using a config setting on a provider or something. But maybe there is some custom Angular build without "helpers"? I suppose I could write some Yeoman/Grunt task to remove/comment the .createComment-s from Angular's source whenever I scaffold a new project. Or maybe you guys know of a fiddle that already does that? And also, this raises my last question: Are those comments somehow crucial to the Angular's normal functioning? And if I remove them, will it cause some kind of instability in my app? Should a just rewrite the CSS and "deal with it"?
Unfortunately for my case, Angular removes all comments from the template during processing. Hence this first attempt resulted in an empty component. The setTimeout call is used in order for HTML rendering to complete before createComment is called.
Here the task is to remove a particular element from the DOM with the help of AngularJS. Approach: Here first we select the element that we want to remove. Then we use remove() method to remove that particular element.
You can use HTML comment syntax instead <! -- --> . The HTML commented out this way still is added to the DOM but only as comment. Basically, because the template section is parsed as HTML not Javascript, I should be using HTML syntax for the comments, right?
Whenever you require to strip HTML tags usign Angular Filter, then this post can help you. If you are working on php then it is very easily use predefine function But in AngularJS you need to make your own filter for remove html tag from string.
The comments are crucial to how Angular handles certain elements. Removing them is not currently an option. What issues are you having with it?
You are able to remove the contents of these angular comments, as well as some of the classes angular attaches to elements (e.g ng-scope) by adding this config to your angular module:
myApp.config(['$compileProvider', function ($compileProvider)
{
$compileProvider.debugInfoEnabled(false);
}]);
According to the angular.js docs, it is actually good to do this in production and should result in a performance boost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With