Skip to content

Instantly share code, notes, and snippets.

@russellf9
Created December 15, 2014 12:29
Show Gist options
  • Save russellf9/d68d8f488b79521813c0 to your computer and use it in GitHub Desktop.
Save russellf9/d68d8f488b79521813c0 to your computer and use it in GitHub Desktop.
Back Button
'use strict';
/**
* A simple directive to use the browser history to implement `back` behaviour
*/
tool.directive('backButton', ['$window', function ($window) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
// note `timeout` required due to IE9 bug
element.bind('click', function(){
setTimeout(function() {
$window.history.back();
},10);
});
}
};
}]);
@russellf9
Copy link
Author

Usage:
<a class="btn btn-default btn-sm" back-button role="button">Back</a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment