增加书签,不再从后台拉数据

This commit is contained in:
luchenqun 2017-05-23 16:39:06 +08:00
parent cd36794c14
commit 373a9ecba4
2 changed files with 13 additions and 3 deletions

View File

@ -86,9 +86,18 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
bookmarkService.addNote(note) bookmarkService.addNote(note)
.then((data) => { .then((data) => {
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
if(data.retCode == 0){
note.id = data.insertId;
note.created_at = $filter('date')(new Date(), "yyyy-MM-dd HH:mm:ss");
note.name = '';
$scope.notes.unshift(note);
$timeout(function() {
timeagoInstance.cancel();
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
}, 100)
}
$scope.preContent = $scope.content; $scope.preContent = $scope.content;
$scope.content = ''; $scope.content = '';
getNotes();
updateEditPos(); updateEditPos();
}) })
.catch((err) => { .catch((err) => {

View File

@ -1305,12 +1305,13 @@ api.post('/addNote', function(req, res) {
params.user_id = req.session.user.id; params.user_id = req.session.user.id;
db.addNote(params) db.addNote(params)
.then((affectedRows) => { .then((insertId) => {
res.json({ res.json({
retCode: 0, retCode: 0,
insertId:insertId,
msg: "添加备忘成功 ", msg: "添加备忘成功 ",
}) })
console.log('addNote affectedRows ', affectedRows) console.log('addNote insertId ', insertId)
}) })
.catch((err) => { .catch((err) => {
console.log('addNote error', err); console.log('addNote error', err);