When writing JSPs, I always use <%-- --%>
instead of <!-- -->
to write any comments, since it will not output to the HTML. I have begun using AngularJS, and I'm wondering if there's any similar kind of comment construct that I could use. It's not absolutely necessary to not have the comments visible in the HTML source, but I much rather them not being there.
With the limited knowledge I have of AngularJS, I'm not sure how they could prevent it from being in the source, but I just want to ask in case there is a way. Perhaps there's also a best practice for comments in AngularJS? Any input would be appreciated.
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.
Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript. Any text between the characters /* and */ is treated as a comment.
It is tempting to do too much work in the AngularJS controller. After all, the controller is where the view first has access to JavaScript via $scope functions. However, doing this will cause you to miss out on code sharing across the site and is not recommended by AngularJS documentation.
AngularJS is a library for dynamic features in HTML/JS/CSS pages. It's not a template language such as JavaServer Pages. As such, it doesn't have a special syntax for comments. You can still use HTML style comments of course.
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