javascript - change value array angularJS 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
).
while raising post request keep array data (your desired data) in body of post request.for example: http.post(url,{(your data(key-ordered pair)}) returns promises promises access results. . hope helpfull
Comments
Post a Comment