if in property in angular 8 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: use property in angular 8

import { Component } from '@angular/core';    
@Component({    
  selector: 'app-root',    
  templateUrl: './app.component.html',    
  styleUrls: ['./app.component.css']    
})    
export class AppComponent {   
  // this is property and you can use in your ts file 
  title = "Data binding using Property Binding";      
  imgUrl="https://static.javatpoint.com/tutorial/angular7/images/angular-7-logo.png";    
} 

// and this is your html code looks like

<h2>{{ title }}</h2> <!-- String Interpolation -->    
<img [src]="imgUrl" /> <!-- Property Binding -->

Example 3: 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:

Html Example