在更新Angular中的Model值时响应数据发生更改

时间:2019-07-08 06:23:29

标签: angular

我创建了一个从API调用接收数据的模型,当我更改Model值时,它也反映了res.data,如果我将res.data分配给其他变量,那么它也会反映出来,请建议我是否做错了事

下面是我的代码

getAttributeDetail = (nodeData: any) => {
let att = new AttributeListModel();
att.attributeDataModel = null;
console.log('nodeData', nodeData)
let apicall = {

  "emailaddress": sessionStorage.getItem('ClientemailAddress'),
  "x-access-token": sessionStorage.getItem('ClientToken'),
  "clientid": sessionStorage.getItem('Clientid'),
  "objecttypeId": nodeData.ObjectTypeId,
}
console.log('apicall', apicall)
this.TreemenuService.GetAttributeDetail(apicall).subscribe(res => {
  console.log('The Value of res.data Befor', res)
  if (res.success == 'true') {
    console.log('The Value of res.data after Sucesss', res.data)
    this.attributeList.attributeDataModel = res.data
    att.attributeDataModel = res.data
    att.attributeDataModel[0].AttributeVal = 'TEST'
    console.log('The Value of res.data modified after loop', this.attributeList.attributeDataModel )
    console.log('The Value of res.data modified after', att.attributeDataModel )
  }
})

0 个答案:

没有答案