0
我如何從Hal表示中獲取任何對象ID?使用角度從HAL表示獲取ID
準確地說,我想從所有用戶列表中的特定用戶獲取此信息。有例子:
{
"_embedded" : {
"users" : [ {
"login" : "user1",
"firstName" : "Bolek",
"lastName" : "Kowal",
"email" : null,
"password" : null,
"gender" : null,
"birthDate" : null,
"_links" : {
"self" : {
"href" : "http://localhost:8080/games-organizer/api/users/1"
},
"user" : {
"href" : "http://localhost:8080/games-organizer/api/users/1"
},
"roles" : {
"href" : "http://localhost:8080/games-organizer/api/users/1/roles"
}
}
}, {
"login" : "user2",
"firstName" : "Lolek",
"lastName" : "Kowalski",
"email" : null,
"password" : null,
"gender" : null,
"birthDate" : null,
"_links" : {
"self" : {
"href" : "http://localhost:8080/games-organizer/api/users/2"
},
"user" : {
"href" : "http://localhost:8080/games-organizer/api/users/2"
},
"roles" : {
"href" : "http://localhost:8080/games-organizer/api/users/2/roles"
}
}
}
最終如何刪除特定用戶使用休息彈簧API和角度/彈簧?我不知道如何在沒有任何用戶(對象)的id的情況下做到這一點。
更新:
我想用這個ID,在調用一些像這樣的方法:
$scope.$on('deleteUser', function (event, id) {
userService.delete({id: id}).$promise.then(
function() {
// Broadcast the event to refresh the grid.
$rootScope.$broadcast('refreshUserGrid');
// Broadcast the event to display a delete message.
$rootScope.$broadcast('userDeleted');
$scope.clearForm();
},
function() {
// Broadcast the event for a server error.
$rootScope.$broadcast('error');
});
});
我想在springRestAPI從數據庫中刪除了一些記錄。
ID? – vertika
這意味着我不知道如何從該表示中的任何用戶獲取id。我應該以任何方式使用鏈接嗎? – smok010
如果你知道你要刪除哪個用戶,那麼最新的問題是什麼? – vertika