Angular 2 by Examples: Difference between revisions

From Han Wiki
Jump to navigation Jump to search
add ngFor to iterate through an array
 
Line 21: Line 21:
}
}
</syntaxhighlight>
</syntaxhighlight>
<console>
$ ##i##testing
COPYING LocalSettings.php
</console>

Revision as of 14:42, 8 July 2016

ngFor to iterate through an array

import { Component } from '@angular/core';

@Component({
        selector: 'my-app',
        template: `
<ul>
        <li *ngFor="let name of names">Hello {{ name }}</li>
</ul>
`
})

export class AppComponent {
        names: string[];

        constructor() {
                this.names = ['Ari','Carlos','Felipe','Nate'];
        }
}

<console> $ ##i##testing COPYING LocalSettings.php </console>