Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ngRepeat exist in Angular 2?

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?

like image 605
CT14.IT Avatar asked May 28 '15 11:05

CT14.IT


People also ask

What is ngRepeat in angular?

AngularJS ng-repeat Directive The ng-repeat directive repeats a set of HTML, a given number of times. The set of HTML will be repeated once per item in a collection. The collection must be an array or an object. Note: Each instance of the repetition is given its own scope, which consist of the current item.

How do I find the NG-repeat index?

Note: The $index variable is used to get the Index of the Row created by ng-repeat directive. Each row of the HTML Table consists of a Button which has been assigned ng-click directive. The $index variable is passed as parameter to the GetRowIndex function.

Why is angular 2 used?

Angular 2 is a framework for building web or mobile applications in HTML and Javascript or Typescript. It's the right choice of framework to use for your web or mobile applications.

What is $Index in AngularJS?

Stay on the bleeding edge of your favorite technologies. $index is a way to show which iteration of a loop you're in. If we set up an ng-repeat to repeat over the letters in 'somewords', like so: <div ng-app="app"> <div ng-repeat="item in 'somewords'.split('')"> {{$index + 1}}.


2 Answers

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> 
like image 187
rckd Avatar answered Sep 30 '22 06:09

rckd


From alpha 28 to 30 it's the following syntax:

import { NgFor } from 'angular2/angular2';  @View({ directives: [NgFor] })    <div *ng-for="#item of items"> 
like image 29
Ajden Towfeek Avatar answered Sep 30 '22 06:09

Ajden Towfeek