Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments in angularjs expression

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?

like image 908
Vedavyas Bhat Avatar asked Nov 01 '22 11:11

Vedavyas Bhat


1 Answers

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.

like image 147
dfsq Avatar answered Nov 09 '22 05:11

dfsq