I am new to angular, I am calling rest api and getting response back successfully but I am not able to iterate that response by ngFor
in my html file .
This is my component.ts file
import { Component, OnInit } from '@angular/core';
import { UserService } from '../services/reg.service';
@Component({
selector: '<app-users>',
templateUrl: 'users.component.html'
})
export class UsersComponent implements OnInit {
users: any = {};
constructor(
private userService: UserService
) { }
ngOnInit() {
this.userService.getUserList().subscribe(
data => {
this.users = data['data'];
// data is in below structure
/* {
status: "Data found",
data: {
1: {
id: "1",
username: "aksahy",
gender: "male"
},
2: {
id: "2",
username: "anand",
gender: "male"
}
}
} */
console.log(this.users);
},
error => {
console.log(error);
}
);
}
}
This is my component.html file .
<div class="container">
<li *ngFor='let userlist of users'>
{{ userlist.gender}}
</li>
</div>