I've been encountering various difficulties with this issue.
Within my "client.ts" class, I have another class named "address.ts" as part of its structure. Inside "Address", there is an element called "addressLocation.ts" where I need to assign the value of "stateShortName" to be "VIC". This specific setting poses a challenge for me.
The client class looks like this:
import { Serializable } from "../../../../services/serializable/Serializable"
import { AddressDetails } from "../address/addressDetails"
import { JobDetails } from "../../jobs/jobDetail/jobDetails"
export class ClientDetails implements Serializable<ClientDetails> {
// all the defined properties
address: AddressDetails = "new AddressDetails";
jobs: JobDetails[];
deserialize(input) {
// deserialization logic
}
deserializeAddressStateShortName(input) {
// function implementation
}
}
In the code above, the address class is initialized as "new AddressDetails".
And here is how the address class is structured:
import { Serializable } from "../../../../services/serializable/Serializable"
import { AddressLocation } from "./addressLocation"
export class AddressDetails implements Serializable<AddressDetails> {
// address details
addressLocation: AddressLocation;
deserialize(input) {
// deserialization process
}
}
The "addressLocation" within Address is set as "new AddressLocation".
import { Serializable } from "../../../../services/serializable/Serializable"
export class AddressLocation implements Serializable<AddressLocation> {
// address location attributes
set stateName(name: string) {
this.stateShortName = name;
}
deserialize(input) {
// deserialization steps
}
}
You can initialize each one using the "deserialize" function.
When fetching data and populating the "client" object which fills in "address" and then subsequently "addressLocation," everything works fine. The client object gets populated by using this.client.deserialize(data)
.
However, I'm trying to figure out how to set the value of "stateShortName" directly in
this.client.address.addressLocation.stateShortName
after creating the client using client = new ClientDetails();
. Any tips on simply setting that particular value?