title: store state of member variable in angular 2 class
body: <pre><code>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) =&gt; {
              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]
      }
  }
  </code></pre>
  
  <p>I return a promise from service lamdaService where i assign data from DB to template/member variable templateModel which gets modified though form in template.html. I want initial/old response to compare it with modified but i am not achieve it, as i've initiated new variable old response which gets updated with form and i get same result for both console.log in save function </p>