Angular 2 loop


#1

I have created simple json and trying to print using *ngFor but its not printing anything. Please help me to know missing part. Below is the code of typescript file as well as html file

Typescript code

export class HomePage {

public users = [
{ name: ‘Jilles’, age: 21 },
{ name: ‘Todd’, age: 24 },
{ name: ‘Lisa’, age: 18 }
];

constructor(private navController: NavController) {

}

HTML file code

<div *ngFor='let user of users'>
{{ user.name }}
</div>


#2

That code works, so you must have an error somewhere else.


#3

Agreed, that looks good to me. A good way to test that angular is working properly is to put something like {{1+2}} into your html and ensure that it outputs a 3 in the view.


#4

Thanks for reply. Yes error was somewhere else.