-
-
Save shashibest/ff8c2881bf80498e3debb2ed34159e4f to your computer and use it in GitHub Desktop.
AngularJS directive to create a functional "back" button
This file contains hidden or 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 hidden or 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