Reena Lakra

Reena Lakra

  • NA
  • 146
  • 56.4k

Undefined value when there is nested model.

May 30 2018 6:31 AM
I have two model with properties like :
  1. export class Users {  
  2. UserId: string;  
  3. FirstName: string;  
  4. LastName: string;  
  5. }  
  1. export class Address{  
  2. AddressId: string;  
  3. Location: string;  
  4. PinCode: string;  
  5. }  
Create one more model to call them, like 
  1. export class AddCustomers {  
  2. UserEntity: Users;  
  3. AddressEntity: Address;  
  4. }  
But whenever, i trying to access like this:
  1. myObject:AddCustomers=new AddCustomers();  
  2. myObject.UserEntity.FirstName="Tim"// it display error, Firstname not defined  

Answers (3)