私は今、角度の新人です私はテーブル "Puntaje"に挿入する前に、ポストグレスデータベースにプレーヤーのスコアを保存するウェブサイトで働いています私はゲームのIDとIDを保存する必要があります私のコードは実際にそれを行いますが、そのようなテーブルに最後に挿入されたIDを取得しようとすると、キーが挿入されていないかのようにクエリが返されますが、ここにコードがあります:
angular.module('clienteJuegoApp').controller('Juego1Ctrl', function ($scope, $http){
$scope.juego = "Survive";
$scope.add = function(){
//First part, saves the gameID and the Player ID into the 1st table
console.log($http.get('http://127.0.0.1:8080/v1/jugador').then(function(response) {
console.log($scope.d = response.data);
console.log("long"+$scope.d.length);
console.log("idjugaor"+$scope.d[$scope.d.length-1].Id);
var datosJuegoJugador={
idjuego: {Id:1},
idjugaor:{Id:$scope.d[$scope.d.length-1].Id}
};
$http.post("http://127.0.0.1:8080/v1/juegojugador", datosJuegoJugador);
console.log("se inserto");
//Second part, retrieve the last inserted Id of the previous table
console.log($http.get('http://127.0.0.1:8080/v1/juegojugador').then(function(response2) {
console.log($scope.dj = response2.data)
console.log("idjuegojugador:"+$scope.dj[$scope.dj.length-1].Id)
var data = {
Idjuegojugador: {Id: $scope.dj[$scope.dj.length-1].Id},
Puntaje: parseInt($("input:text[name=puntaje]").val())
};
console.log(data)
$http.post("http://127.0.0.1:8080/v1/puntaje", data);
}))
}))}
どうしてですか?どうすれば修正できますか? ありがとうございます。
ありがとう、それは魅力のように動作します! –
素晴らしい:-)良い一日を –