I have some HTML tags which have ng-clicks and ng-ifs. Inside the respective expressions, I make function calls and pass in parameters, some of which are literals (mostly just true or false). So I would like to add a comment as to what a literal means, but angular doesn't seem to be able to parse this correctly. (I realize passing literals is not the brightest idea but I would nevertheless like to know the answer)
<button class='someclass' ng-click='somefunction(val1, val2, true /* explanation for literal */)' > </button>
How do I add comments in angular expressions?
No, comments are not supported. Parser sees /
as an mathematical operator (see source code) which expects primary expression after it: e.g. something starting with (
, or [
, etc. However there is no valid expression in javascript that can include *
immediately after /
character. So parser throws an exception: Token '*' not a primary expression
.
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