I want to perform a reload of a route ONLY when there's not a route change, in other words reload a controller when a button that takes to its route is clicked. In my view in the ng-click directive I call the following method:
this.reload = function() {
$scope.$on('$routeChangeStart', function(event, next, current) {
if($route.current == $route.next) {
$route.reload();
}
})
}
The code inside the condition is never triggered because there's not a change in the route. I'm a beginner in angularJS, so any help will be appreciated :)
I would handle the two things you mentioned above separately.
Register an event listener that listens for routeChangeStart.
html
controller
Also, in your above example the $routeChangeStart function executes a callback and is passed the event, next, and prev objects. You should be using those arguments in your if statements, not $route.current or $route.next.