How to reload the controller when the user click the back button???
I am using AngularJS v1.6.2 and angular-ui-router 0.4.2
The states:
...
.state('cars.bmw', {
cache: false,
url: '/bmw',
templateUrl: 'pages/cars/bmw.html?v=' + version
})
.state('cars.audi', {
cache: false,
url: '/audi',
templateUrl: 'pages/cars/audi.html?v=' + version
})
...
Check the location path and I'm injecting {{}}
the header and the title:
...
if($location.path() === '/cars/bmw')
{
$scope.pageHeader = "BMW Cars";
$scope.curentMenu = "CARS";
$scope.title = My Car Collection BMW";
}
...
the menu links:
...
<a ui-sref="cars.bmw" ui-sref-opts="{reload: true}">BMW</a>
...
The problem is for example if I am in /cars/BMW
path and click the back button to /cars/audi
, the title, header and curentMenu
don't change, I have to manually refresh the page to reload the controller.