if you have a controller to manipulate $scope variables in Angular.js, is there an idiomatic way to:
Just after asking, I finally found one way to solve this using $route.reload().
myapp.Controller('SampleController', function($location, $route) {
$scope.navTo = function(url) {
if ($location.path() === url) {
$route.reload();
} else {
$location.path(url);
}
}
});
I'm still thinking, that there must be some more elegant solution, but this definitely works for me.
If you are using angular-ui-router then you should do it in this way:
myapp.Controller('SampleController', function($state) {
$scope.navigate = function (stateName) {
if ($state.is(stateName)) {
$state.reload();
} else {
$state.go(stateName);
}
}
});