加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

EmbeddedViewRef

发布时间:2020-12-17 08:59:06 所属栏目:安全 来源:网络整理
导读:class EmbeddedViewRef extends ViewRef { get context(): C get rootNodes(): any[] } 描述 Represents an Angular View. 代表一个angular视图 A View is a fundamental building block of the application UI. It is the smallest grouping of Elements wh

class EmbeddedViewRef extends ViewRef {
get context(): C
get rootNodes(): any[]
}

描述

Represents an Angular View.
代表一个angular视图
A View is a fundamental building block of the application UI. It is the smallest grouping of Elements which are created and destroyed together.
一个view是应用程序UI的基本构建块。它是可以一起创建和销毁的最小的元素组合。
Properties of elements in a View can change,but the structure (number and order) of elements in a View cannot. Changing the structure of Elements can only be done by inserting,moving or removing nested Views via a ViewContainerRef. Each View can contain many View Containers.
一个视图中元素的属性可以更改,但View中的元素的结构(数量和顺序)不能。
更改Elements的结构只能通过ViewContainerRef插入,移动或删除嵌套视图来完成。
每个视图都可以包含许多视图容器。

例子

如有以下模板

Count: {{items.length}} <ul> <li *ngFor="let item of items">{{item}}</li> </ul>

我们有了两个 templateRef

外层templateRef
Count: {{items.length}}

<ul>
  <ng-template ngFor let-item [ngForOf]="items"></ng-template>
</ul>

内层templateRef

<li>{{item}}</li>

请注意,原始模板分为两个单独的TemplateRefs。

然后将外部/内部TemplateRefs组合成如下所示的视图:

<!-- ViewRef: outer-0 -->
Count: 2
<ul>
  <ng-template view-container-ref></ng-template>
  <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
  <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
</ul>
<!-- /ViewRef: outer-0 -->

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读