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?
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.
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.
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.
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}}.
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>
From alpha 28 to 30 it's the following syntax:
import { NgFor } from 'angular2/angular2'; @View({ directives: [NgFor] }) <div *ng-for="#item of items">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With