Skip to content

Instantly share code, notes, and snippets.

@krazylearner
Forked from jakemmarsh/directives.js
Created June 15, 2017 06:34
Show Gist options
  • Save krazylearner/6238816b33a8c66342666836d12a43d2 to your computer and use it in GitHub Desktop.
Save krazylearner/6238816b33a8c66342666836d12a43d2 to your computer and use it in GitHub Desktop.
AngularJS directive to create a functional "back" button
app.directive('backButton', function(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', goBack);
function goBack() {
history.back();
scope.$apply();
}
}
}
});
<a href back-button>back</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment