What is template in Angular?

Template                                                                                  



A template looks like regular HTML, except that it also contains Angular template syntax, which alters the HTML based on your application's logic and the state of application and DOM data. Your template can use data binding to coordinate the application and DOM data, pipes to transform data before it is displayed, and directives to apply application logic to what gets displayed.



For example, here is a template for the Tutorial's HeroListComponent.


<h2>Hero List</h2>

<p><em>Select a hero from the list to see details.</em></p>

<ul>

  <li *ngFor="let hero of heroes">

    <button type="button" (click)="selectHero(hero)">

      {{hero.name}}

    </button>

  </li>

</ul>


<app-hero-detail *ngIf="selectedHero" [hero]="selectedHero"></app-hero-detail>

This template uses typical HTML elements like <h2> and <p>. It also includes Angular template-syntax elements, *ngFor, {{hero.name}}, (click), [hero], and <app-hero-detail>. The template-syntax elements tell Angular how to render the HTML to the screen, using program logic and data.


The *ngFor directive tells Angular to iterate over a list.

{{hero.name}}, (click), and [hero] bind program data to and from the DOM, responding to user input. See more about data binding below.

The <app-hero-detail> element tag in the example represents a new component, HeroDetailComponent. The HeroDetailComponent defines the hero-detail portion of the rendered DOM structure specified by the HeroListComponent component.


Notice how these custom components mix with native HTML. 



https://angular.io/guide/architecture-components







Comments

Popular posts from this blog

pxSubscript and pxListSubscript Properties In Pega

Frequently Used Date Expressions In Pega

pyForEachCount In Pega