gpt4 book ai didi

javascript - 在发布到 API 之前更改数组 javascript 中的一些值

转载 作者:太空宇宙 更新时间:2023-11-03 15:12:15 25 4
gpt4 key购买 nike

我有一个数组:

[{"IDAlokasiEmiten":154,"IDOrganization":12,"NamaOrganization":null,"CodeEmiten":"ANTM","NameEmiten":"AAneka Tambang (Persero) Tbk"},{"IDAlokasiEmiten":0,"IDOrganization":null,"NamaOrganization":null,"CodeEmiten":"ADHI","NameEmiten":"Adhi Karya (Persero) Tbk"}]

如何在发布到 API 之前更改某些值?

我想 POST 到 API 到:

[{"IDAlokasiEmiten":0,"IDOrganization":12,"NamaOrganization":null,"CodeEmiten":"ANTM","NameEmiten":"AAneka Tambang (Persero) Tbk"},{"IDAlokasiEmiten":0,"IDOrganization":12,"NamaOrganization":null,"CodeEmiten":"ADHI","NameEmiten":"Adhi Karya (Persero) Tbk"}]

这是我的 AngularJS:

// GET Detail Alokasi Emiten
$scope.emit.detailDaftarEmiten = [];
$scope.addItemAlokasi = function () {
$scope.emit.detailDaftarEmiten.push({
IDAlokasiEmiten: 0,
IDOrganization: 12,
NamaOrganization: '',
CodeEmiten: $scope.emit.detailDaftarEmiten.CodeEmiten,
NameEmiten: $scope.emit.detailDaftarEmiten.NameEmiten
});
$scope.emit.detailDaftarEmiten.IDAlokasiEmiten = '';
$scope.emit.detailDaftarEmiten.IDOrganization = '';
$scope.emit.detailDaftarEmiten.NamaOrganization = '';
$scope.emit.detailDaftarEmiten.CodeEmiten = '';
$scope.emit.detailDaftarEmiten.NameEmiten = ''
};
$scope.resetForm = function () {
$scope.emit.detailDaftarEmiten.IDAlokasiEmiten = '';
$scope.emit.detailDaftarEmiten.IDOrganization = '';
$scope.emit.detailDaftarEmiten.NamaOrganization = '';
$scope.emit.detailDaftarEmiten.CodeEmiten = '';
$scope.emit.detailDaftarEmiten.NameEmiten = ''
};
$scope.deleteItem = function (index) {
$scope.emit.detailDaftarEmiten.splice(index, 1);
};
$scope.getTotalItems = function () {
return $scope.detailDaftarEmiten.length;
};

但它不起作用:(

我想为 (IDAlokasiEmiten=0IDOrganization=12) 设置所有值数组。

最佳答案

var obj=your code;
obj[0]["IDOrganisation"]=12;
//0 -> first object in array

这是简单的javascript。您应该访问 MDN 并了解更多信息...

关于javascript - 在发布到 API 之前更改数组 javascript 中的一些值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40660375/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com