Angular Components

What Is an Angular Component?

Components are like the basic building block in an Angular application. An Angular app contains a tree of Angular components.

It contains #binding and #interpolation in Angular App

A component is just a class that serves as a controller for the user interface. It consists of three parts – some TypeScript code, an HTML template, and CSS styles.

For more

a) Binding

This is the example like we can disable a button after it has been clicked.

@Component(...)
export class SomeComponent {
  clicked = false
}
<button [disabled]="clicked"></button>

In other way we can use () parenthesis to bind the action. Let’s try the method to change the “Clicked” property to false – This is the very basic event handling in Angular.

@Component(...)
export class SomeComponent {
  clicked = false;

  handleClick() {
    this.clicked = true;
  }
}
<button [disabled]="clicked" (click)="handleClick()"></button>

b) Interpolation

Interpolation markup with embedded expressions is used by Angular to provide data-binding to text nodes and attribute values.

An example of interpolation is shown below:

<code class="lang-html"><a ng-href="img/{{username}}.jpg">Hello {{username}}!</a></code class="lang-html">

to be Continue…

You May Also Like

SASS

CSS Grid Example

CSS Grid Properties

Image Responsive

Leave a Reply

Your email address will not be published. Required fields are marked *