AngularJS directive to create a functional "back" button
directives.js
app.directive('backButton', function(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', goBack);
function goBack() {
history.back();
scope.$apply();
}
}
}
});
index.html
<a href back-button>back</a>