。我有一個觀點,其中用戶可以像這樣添加和刪除項目:保存添加和Hi我使用angularJs在我的客戶端刪除用戶
app.controller('demoController', function($scope) {
// initial items
$scope.items = [
'item one',
'item two',
'item three'
];
// add an item
$scope.add = function() {
$scope.items.push($scope.input);
};
// remove an item
$scope.remove = function(index) {
$scope.items.splice(index, 1);
};`enter code here`
});
當用戶結束了,我想他點擊一個按鈕。之後我會將所有添加和刪除的項目發送到服務器以更新數據庫。我無法每次點擊都做到這一點,因爲我需要所有信息來填充服務器部分中的電子郵件。我知道如何刪除和添加項目,但我不知道如何找到刪除的項目並添加項目並將它們發送到服務器。請任何人知道我該如何做到這一點? 非常感謝。
所以你想發送用戶,他們添加和刪除了什麼? –
是的,@亞當哈里森我非常想做到這一點。 – Elmohmoh
爲什麼不將他們已經移除的數據推送到數組,以及他們已經添加到數組中,然後使用$ http使用ajax將它們發送到後端? –