Component
export class AllUserComponent implements OnInit {
//Here is saving all users from database
allUsers: Array<Object>;
roleName: any[] = []; //here I want roles property from each object from allUsers
constructor(private userService: UserService) {}
ngOnInit() {
//Take from UserService getAll method and subscribe to add all users from database
this.userService.getAll().subscribe(data => {
this.allUsers = data.allUsers;
console.log(this.allUsers)
});
}
Service
getAll(): Observable<AllUsers> {
return this.http.get<AllUsers>(this.url);
}
Model
export interface AllUsers{
allUsers: string[];
}
I want to get roles which are nested values in each object of allUser array and add it to roleName array and display in Roles column in table in HTML view.

this.allUsers?