node.js - Why page not redirecting in AngularJS+Express -
i making demo site angular express seed brian ford (thanks lot), after edit post not redirecting listing url. edit operation doing fine not redirecting listing page after hit submit button . in chrome showing pending in status never ends... codes bellow:
angular controller
function editpostctrl($scope, $http, $location, $routeparams) { $scope.form = {}; $http.get('/api/posts/details/' + $routeparams.id). success(function(data) { $scope.form = data.post; }); $scope.editpost = function () { $http.post('/api/posts/edit/' + $routeparams.id, $scope.form). success(function(data) { $location.path('/posts'); }); }; };
express app
app.post('/api/posts/edit/:id',api.adminlogincheck,api.editpost);
api.js
exports.editpost = function (req, res,next) { console.log("editpost"); var id = req.params.id; req.body.slug = req.body.title.split(' ').join('-').tolowercase(); delete req.body._id; mymongodb.update({slug:id},'posts',req.body, function(error,results){ if(error){ console.log(error); res.json(false); }else{ res.json(true); } }); };
what doing wrong? in advance
Comments
Post a Comment