Search code examples
javascriptangularsyntaxnotation

What does ${...} syntax mean in Angular? The money symbol prepending curly braces?


I can't seem to find what the following syntax means in Angular (or perhaps it's just Javascript):

name() {
     return ${this.firstName} ${this.lastName};
}

specifically the ${...}?

Is it an Angular thing or is it just Javascript?

-thanks


Solution

  • These are known as Template literals allowing you to essentially inject expressions into a multiline string without any messy concatenation, but you must enclose them inside back-ticks.

    name() {
         return `${this.firstName} ${this.lastName}`;
         // as opposed to this.firstName + ' ' + this.lastName
    }