angular interpolation code example

Example 1: angular property binding

// component.ts

    @Component({
      templateUrl: 'component.html',
      selector: 'app-component',
    })
    export class Component {
      name = 'Peter';

      updateName() {
        this.name = 'John';
      }
    }

Example 2: angular interpolation

<p>{{title}}</p>
<div><img src="{{itemImageUrl}}"></div>

Example 3: ? operator in angular interpolations

{{element.source == 1 ? 'upwork' : (element.source == 2 ? 'refer from friend' : '')}}

Example 4: angular property binding

import { Component } from "@angular/core";
@Component({
   selector: 'app-example',
  template: `
              <div>
              <input [value]='myText'></span>       
              </div>
              `
})
export class AppComponent {
  myText: string = "Hello World";
}

Tags:

Misc Example