Upon stumbling across a popular answer with +50 upvotes and an intriguing comment, I learned about a unique way to define Angular variables in templates without having them rendered as text. By simply ending the expression with a semicolon and double quotes, like so: ;""
.
To my surprise, upon testing, this unconventional method actually worked. Here's an example:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="">
<p>This variable is rendered: {{ text1 = 'yes' }} </p>
<p>This variable isn't: {{ text2 = 'yes';"" }}</p>
</div>
While I understand that using ngInit is the recommended way to initialize a variable, the fact that it received +50 upvotes made me question if this could possibly be a documented feature. Unfortunately, there doesn't seem to be any official references to support this unconventional approach.
If this turns out to be more of a workaround rather than a feature, potentially taking advantage of a rendering quirk, should I be concerned about its stability and likelihood of being rectified in future updates?