16 April 2020

Property Binding example in angular

  • Open Command prompt and use below commands to create angular project
  • E:
  • cd E:\TestProjects\Angular
  • ng new Property-Binding-example-in-angular --style=scss --routing --skip-install
  • cd Property-Binding-example-in-angular
  • npm install
  • Open project in visual studio code.
  • add logo.png in "assets/images" folder
  • Open app.component.ts file and update code as below

  • import { Component } from '@angular/core';

    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss']
    })
    export class AppComponent {
      constructor() { }
       logoPathstring = 'assets/images/logo.png';
      ngOnInit() {}
    }
  • Open app.component.html file and update code as below

  • <h1>Property Binding example in angular</h1>
    <img [src]="logoPath" /><br>

    Output:

    No comments:

    Post a Comment