Angularjs has some sweet built-in directives. Sometimes it can be confusing when to use the curly braces around expressions in directive attributes and when not to. Here are a couple rules.
By “curlies”, I mean curly braces. The difference of when to use or not use them looks like the following.
Or despise them:
Two Rules of Thumb
Here are two rules that will serve you well when deciding whether or not to use curlies.
- Assume no curlies in Angular directive attribute values. Most directives don’t use them.
Two Examples with Curlies
As in the source of an image, such as:
As in a link to an html page, such as:
Something more Precise?
Is there something more precise than these two rules of thumb? Why does Angular make an exception for these two cases, thus causing us to try to remember our rules of thumb?