0
我需要添加一個角色+傳遞給leveldb的用戶。這是添加項目的代碼:將一個元素髮布到AngularJS
$scope.addItem = function() {
$scope.username;
$http({
method: 'POST',
url: '/addUser',
key: {
username: $scope.username,
params: {
value: {
password: $scope.password,
role: $scope.role
}
}
}
}).then((result) => {
$scope.getAllItems();
}).catch((reason) => {
console.log(reason);
})
};
如何使控制器中的結構?控制檯返回:
[WriteError: put() requires a key argument]
這是拋出錯誤的代碼的一部分?錯誤中的任何行信息?另外,我並不確定明白你想做什麼,我想這是更大項目的一部分,你能解釋一下嗎? – kazu
我想在一個關卡數據庫中插入一個用戶。這是角度和網址中控制器代碼的一部分:'/ addUser',是要插入新用戶的模型的網址。 [WriteError:put()需要一個關鍵參數]它指的是模型需要關卡數據庫的關鍵字。問題在於角度控制器中的結構不是這樣。在模型中我有這樣的:context.db.put(用戶名,{密碼,角色} –