我在角度4项目中有json对象。
NationalityList: any[]; Nationality: any = {};
在具有名为" Nation"的属性的两个json对象中。 EthnicList持有多个国家名单。国籍用于绑定Entry字段中的模型。当我从EthnicList编辑一个国家;我正在抄袭"国籍"并在文本框中显示。当我输入文本框时,它在国籍列表和国籍中都有效。如何防止这种情况?
GetNationalities() {
this.loading = true;
var param = {};
this.JsonApiService.CommonService('HCP/GetAllNationalityList', this.JsonApiService.encrypt(JSON.stringify(param)).toString()).subscribe((Resp) => {
this.NationalityList = this.JsonApiService.decrypt(Resp);
this.loading = false;
this.DestroyDataTable();
});
}
SaveNationality(f: NgForm) {
if (!f.valid) {
this.InitializeAllValidation(f)
return;
}
this.Nationality.Mode = 'ADD';
this.JsonApiService.CommonService('HCP/SaveNationality', this.JsonApiService.encrypt(JSON.stringify(this.Nationality)).toString()).subscribe((Resp) => {
var Response = this.JsonApiService.decrypt(Resp);
if (Response.Status == true) {
this.toastr.success('Nationality has been added successfully', '');
this.GetNationalities();
this.Cancel();
this.DestroyAllValidation(f);
}
else {
if (Response.ResultMsg.length > 0)
this.toastr.error(Response.ResultMsg, '');
else
this.toastr.error('Unable to save Nationality', '');
}
});
}