of the 中 的-content-template-container

In angular, there are three such built-in label, but there is no explanation in the angular document, there is only a simple description in api, and explore a long time to get to know Editor's Note.


  <ng-content select=".header">

  <ng-content select=".footer">


ng-content has a select attribute, the attributes can be selected corresponding to the embedded tag, which means that .header selected class = header label to the current position of the filling

  <div class="header">
  <div class="footer">

General layout class components are implemented using ng-content, such as ng-zorror layout of components may be implemented using ng-content

of container

ng-container at the interface is no sense in reviewing the elements of the browser, you can not see it, container means that container. Installed only things that will not be displayed.
  <h1> test </ h1> 
</ container-of>



the template

template is a template meant, ng-template tag is mainly used to load a template.

  <h2>模板</ h2> 
</ the-template>

  But if so, the browser will not render. You must use [ngif] = ture or ngTemplateOutlet to let rendered template content

Use [ngif] = true

<ng-template [ngIf]="true" ]>


 Use ngTemplateOutlet

<a container-* ngTemplateOutlet = " hello " > </ container-of> 
 <a template #greet> <span> Hello </ span> </ the-template>



Context template in a nested assembly

Primeng used when the table element, there will be nested ng-template, and can be obtained in the object context. This is how to do it?

Can pass a context ngTemplateOutlet, go directly to the object is passed like

<table style="width: 100%">
    <th *ngFor="let label of labellist">{{label}}</th>
  <ng-container *ngFor="let item of data;let i = index">

      <ng-container *ngFor="let row of tableColumn">
        <td style="" align="center">
          <ng-container *ngIf="row.prop">
          <ng-container *ngIf="row.scope">
            <ng-container *ngTemplateOutlet="row.scope;context:{row:item}"></ng-container>


<app-apptable [data]="data">
  <app-app-col label="用户名" prop="username"></app-app-col>
  <app-app-col label="密码" prop="pwd"></app-app-col>
  <app-app-col label="昵称" prop="pwd"></app-app-col>
  <app-app-col label="测试" scope="scope">
    <ng-template #scope let-data="row">
      <span style="color: red">00-{{data.username}}</span>

In ng-teamplate in #scope is the current name of the template reference, let-xxxx is defined for accepting context object properties of the current scope,

Then xxx class scope template, can be used to let-xxx is the point that the object ngTemplateOutlet context transfer.

My understanding is almost over in front of the three labels

Guess you like

Origin www.cnblogs.com/boxrice/p/12604367.html