trying to access the child member(is an array) of parent interface.
But getting undefined.
export class Address {
id: number;
city: string;
state: string;
}
import { Address } from './address';
export class User {
id: number;
name: string;
alladdresses: Address[];
}
in my component - the declaration are
users: User[] = [];
address: Address[] = [];
and my http.get is
selectUser(user: User) {
let url = "http://localhost:8080/users/" + user.id
this.http.get<User>(url).subscribe(
res => {
//console.log(res);
this.selectedUser = res;
console.log('selected user is:', this.selectedUser);
},
error => {
console.log('error while getting user for ', user.id);
},
() => {
console.log('complete');
}
);
}
and the json response of user is

here the selected user I am displaying on the page, and some action on page calling another function to access the addresses - the array
createAddress() {
let newAddress: Address = {
id: null,
city: "new city",
state: "new state"
}
console.log(this.selectedUser)
let address: Address[] = this.selectedUser.alladdresses
//address.push(newAddress);
console.log(address);
}

this.selectedUser.addressesinstead ofthis.selectedUser.alladdressesin yourconsole.log?