javascript - Gets redirected to default app route when deleting comment using Angular JS and Laravel -
i developing application using laravel , angularjs users may write , delete comments.
on home screen, user able view , delete of his/her comments , when list should updated.
my problem when press delete button redirected login page default route.
$routeprovider.otherwise({ redirectto : '/login' });
i'm using laravels resource controller
route::resource('comment', 'commentcontroller');
when go home page again comment deleted.
my comment service uses delete comment:
app.factory('commentservice', function($http) { return { destroy: function(id) { return $http.delete('comment/' + id); } }; });
in home controller have created function delete comment.
app.controller('homecontroller', function($scope, $location, authenticationservice, commentservice) { $scope.deletecomment = function(id) { commentservice.destroy(id).success(function() { commentservice.get().success(function(data) { $scope.comments = data; $scope.order = 'end_date'; }); }); };
how can prevent site redirecting login page when delete comment?
the best redirect recent page if logged in, , if i'm not should redirected login page. (e.g. if @ home page redirected home page if type in url doesn't exist or if delete comment)
the login system created these tutorials david mosher:
not sure you've figured out, in case lands here, below 1 thing responsible (and in code finished debugging):
<a href="#" ng-click="deletecomment()">x</a>
this both run deletecomment , follow route #
. adding href="#"
(or href=""
matter) bad habit, <a></a>
can used without href, , in case, should. should work without redirect:
<a ng-click="deletecomment()">x</a>
hope helps who'd land here ;)
Comments
Post a Comment