WEB DEVELOPER SITE
PYTHONJAVA
TUTORIALS
 

Angular 7 Binding


In Angular 7, property binding is used to pass data from the component class (component.ts) and setting the value of the given element in the user-end (component.html).

Property binding is an example of one-way databinding where the data is transferred from the component to the class.

The main advantage of property binding is that it facilitates you to control elements property.

For example

We are going to add a button to "component.html" page.

  1. <p>  
  2.   Server2 is also working fine.  
  3. </p>  
  4. <button class="btn btn-primary">Add Server</button>  

component.ts file:

  1. import { Component, OnInit } from '@angular/core';  
  2.   
  3. @Component({  
  4.   selector: 'app-server2',  
  5.   templateUrl: './server2.component.html',  
  6.   styleUrls: ['./server2.component.css']  
  7. })  
  8. export class Server2Component implements OnInit {  
  9.   
  10.   constructor() { }  
  11.   
  12.   ngOnInit() {  
  13.   }  
  14.   
  15. }  

Output:

Angular 7 Property Binding