I am borrowing an example here to implement Back button:
How to implement history.back() in angular.js
The way I did it was to create a function back()
:
http://jsfiddle.net/qhoc/WaRKv/110/
app.controller('Ctrl', ['$scope', '$window', '$location', function($scope, $window, $location) {
$scope.log = function() {
console.log($location.path());
};
$scope.back = function() {
$window.history.back();
console.log($location.path());
};
}]);
But it doesn't work. The event is hit but the location output in console log doesn't change.
Please help
UPDATE 12/28:
I ran http://jsfiddle.net/WaRKv/111/ and did the following:
- Click Link 1 once
- Click Link 2 once
- Then finally click Back once.
Please see below screenshot. It doesn't work still as the Back button should log Link 1 but it kept showing Link 2.