Reputation: 49384
Using Angular2 I'm trying to make a list from an array...something like:
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: `
<ul>
<li *ngFor="">
{{names}}
</li>
</ul>
`,
})
export class AppComponent {
names = ['name1', 'name2', 'name3'];
}
How can I get something like this to work?
Upvotes: 0
Views: 3129
Reputation: 7348
If you came here looking for Angular Framework v2's syntax - not AngularJS v2 like me here it is:
<ul>
<li *ngFor="let name of names;">
{{name}}
</li>
</ul>
Not saying anyone did anything wrong in the question or anything, their versioning and angular v.s. older angularjs is confusing IMO
Upvotes: 0
Reputation: 1974
Should be
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: `
<ul>
<li *ngFor="#name of names">
{{name}}
</li>
</ul>
`,
})
export class AppComponent {
names = ['name1', 'name2', 'name3'];
}
Upvotes: 7