Skip to content

Instantly share code, notes, and snippets.

@brianbroken
Forked from jakemmarsh/directives.js
Created May 24, 2017 05:56
Show Gist options
  • Save brianbroken/b43ea4b176aa20edb13273307ad5ab47 to your computer and use it in GitHub Desktop.
Save brianbroken/b43ea4b176aa20edb13273307ad5ab47 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