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

* in * ngFor在angle2中的含义是什么?

发布时间:2020-12-17 09:41:47 所属栏目:安全 来源:网络整理
导读:以下样例中的* before ngFor的含义是什么,为什么需要? div *ngFor="#hero of heroes" (click)="selectHero(hero)" {{hero.name}}/div ngFor只能应用于 template. * ngFor是可以应用于任何元素的简短形式, template元素隐含地创建在场景后面. https://angula
以下样例中的* before ngFor的含义是什么,为什么需要?
<div *ngFor="#hero of heroes" (click)="selectHero(hero)">
  {{hero.name}}
</div>
ngFor只能应用于< template>. * ngFor是可以应用于任何元素的简短形式,< template>元素隐含地创建在场景后面.

https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html

Syntax

  • <li *ngFor="let item of items; let i = index">...</li>
  • <li template="ngFor let item of items; let i = index">...</li>
  • <template ngFor let-item [ngForOf]="items" let-i="index"><li>...</li>

所有structural directives的模式都是一样的

Plunker example

更新

使用2.0.0最终版本< ng-container>被引入,其行为类似于< template> (实际上并不添加到DOM中的包装元素),但支持* ngFor =“…”语法.

(编辑:李大同)

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

    推荐文章
      热点阅读