Angular 2 中是否存在 ngRepeat? [英] Does ngRepeat exist in Angular 2?

查看:13
本文介绍了Angular 2 中是否存在 ngRepeat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了与 Angular 2 及其 ng-repeat 实现相关的各种问题跟踪器条目,但就目前而言,我还没有真正确定它是否真的存在.

是否可以在 angular 2 中使用 ng-repeat?

解决方案

Angular 2.0 Release

my-component.ts:

import { Component } from 'angular2/core';@成分({选择器:'我的组件',templateUrl: './my-component.html'})导出类 MyComponent{公共值:number[] = [1, 2, 3];}

my-component.html:

{{ 价值 }}

I've read various issue tracker entries in relation to Angular 2 and its implementation of ng-repeat, but as it stands I haven't actually worked out if it actually exists yet.

Is it possible to use ng-repeat in angular 2?

解决方案

Angular 2.0 Release

my-component.ts:

import { Component } from 'angular2/core';

@Component({
  selector: 'my-component',
  templateUrl: './my-component.html'
})
export class MyComponent{
  public values: number[] = [1, 2, 3];
}

my-component.html:

<div *ngFor='let value of values; trackBy: index;'>
  {{ value }}
</div>

这篇关于Angular 2 中是否存在 ngRepeat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆