Reputation: 55
I am using ng-routing
in application in angularjs. I have my own back button. I want to go back to previous page from where I have redirected to this page? Kindly help me?
Upvotes: 2
Views: 6246
Reputation: 4756
A simple directive for that
app.directive('historyBackward', ['$window', function($window) {
return {
restrict: 'A',
link: function(scope, elem, attrs) {
elem.bind('click', function() {
$window.history.back();
});
}
};
}]);
In your HTML
<button history-backward>back</button>
Upvotes: 1
Reputation: 1120
You can use history.back()
on click of your back button. this will redirect to your previous page using browser's history.
Upvotes: 3