export class RSDLeadsComponent implements OnInit{
templateModel:RSDLeads = {
"excludedRealStateDomains": [{"domain":""}],
"leadAllocationConfigNotEditables": [{"attributeName":""}]
};
oldResponse:any;
constructor(private lambdaService:LambdaService, @Inject(APP_CONFIG)private config:IAppConfig ){};
ngOnInit():void{
this.getFormData();
};
getFormData():void{
let getPayload = {
"pageId": "DomainLeads",
"operationType": "view"
};
this.lambdaService.getResponse('LAConfigLambda', getPayload).then((data:any) => {
const tempData = data;
this.templateModel.excludedRealStateDomains = data.excludedRealStateDomains;
this.oldResponse = tempData.excludedRealStateDomains;
});
};
save(model: RSDLeads, isValid: boolean):void{
console.log("oldResponse",this.oldResponse);//oldResponse [Object, Object, Object]
console.log("templateModel",this.templateModel.excludedRealStateDomains);//templateModel [Object, Object, Object]
}
}
I am returning a promise from the service lambdaService where I assign data from the database to the template/member variable templateModel which gets modified through a form in template.html. I want the initial/old response to compare it with the modified response, but I am unable to achieve that. Despite initiating a new variable, oldResponse, which should capture the original data, both console.log statements in the save function are showing the same result.