EmbeddedViewRef

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 -->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值