I have been told that using ampersands in angular templates is bad practice since '&' is reserved in HTML, but I see it in examples for angular all the time.
To be clear, would it be safe to write
<div ng-show="bool1 && bool2"></div>
in an angular template?
I'm not interested in knowing if it works (it does), but if there are any edge cases where this could cause problems or if it's in fact discouraged.
Ampersands in business writing Answer: You can use ampersands in titles, signage and website buttons where space is limited or the ampersand is part of an organisation's branding. Use and, not ampersands in business writing, even for emails. It is more professional.
That's because ampersands are usually only used for display type–the large or eye-catching type used in headlines, signage, and advertisements–so the character can be more ornate, even in fonts that are primarily designed for text.
Although ampersands are thought of as informal, if the ampersand is officially part of a company name, it's best to use the ampersand instead of writing out the word “and.” For example, you write “Tiffany & Co.,” “Procter & Gamble,” and “AT&T” with ampersands.
Ampersands are completely correct when they're part of a proper name ( Fromage & Cracotte LLP ) or an official citation format ( Bus. & Prof. Code § 17200 ). Otherwise, ampersands should be handled like any other contraction: the more formal the document, the less they should be used.
It's fine. The HTML5 spec explicitly allows unencoded ampersands if they don't look like a character reference (such as ©
). Sure, for some things like URLs it's better to be consistent and escape them. But for &&
with spaces around it, there's no chance that the browser will misinterpret the data, and &&
is significantly less readable.
Relevant Sections of the spec:
I use ampersands in my Angular html templates too and never had a problem with them, but the best way to see if it's safe for you to use them is to just test their effect in a test app that resembles yours I guess...
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