-
-
Save krazylearner/6238816b33a8c66342666836d12a43d2 to your computer and use it in GitHub Desktop.
AngularJS directive to create a functional "back" button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('backButton', function(){ | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) { | |
element.bind('click', goBack); | |
function goBack() { | |
history.back(); | |
scope.$apply(); | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href back-button>back</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment