c# - change some value in array javascript before post to API -
i have array :
[{"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"}]
how change values before post api?
i want post api into:
[{"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"}]
here angularjs:
// 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; };
but doesn't work :(
i want set value array (idalokasiemiten=0
, idorganization=12
).
var obj=your code; obj[0]["idorganisation"]=12; //0 -> first object in array
this simple javascript. should visit mdn , learn bit more of it...
Comments
Post a Comment