I have directive which is site header with back button and I want on click to go back to the previous page. How do I do it in the angular way?
I have tried:
Ideally use a simple directive to keep controllers free from redundant $window
app.directive('back', ['$window', function($window) { return { restrict: 'A', link: function (scope, elem, attrs) { elem.bind('click', function () { $window.history.back(); }); } }; }]);
Use like this:
Back