Variables In Component

In Angular, We use {{ }} to insert javascript result in component

@Component({
  selector: 'app-root',
  template: `
  1 + 1 = {{ 4 }}
`,
  standalone: true
})
  • demo

    image 12.png

And We can use variable like this.

import {Component} from '@angular/core';
 
@Component({
  selector: 'app-root',
  template: `
    Hello {{city}} 
  `,
  standalone: true,
})
export class AppComponent {
  city = 'Taiwan'
}