I am trying to reload a route from my controller using $route.reload() but nothing is happening. Here's my controller:
app.controller("FooController", function($scope, data, $route) {
$scope.model = data.model;
$scope.meta = data.meta;
$scope.reload = function() {
return $route.reload();
};
});
I'm using angular-route-segment for my routes and the associated route looks like this:
app.config(function($routeSegmentProvider) {
$routeSegmentProvider.segment("foo", {
templateUrl: templatesRoot + "/tickers/oldest.html",
controller: "FooController",
resolve: {
data: function($http) {
return $http.get("/api/foos").then(function(response) {
return {
model: response.data.foos,
meta: response.data.meta
};
});
}
},
untilResolved: {
templateUrl: templatesRoot + "/loading.html"
}
});
});
Inject $routeSegment
instead of $route
.
The property chain
is an array of segments splitted by each level separately and each element will have a reload
method.
For example:
$scope.reload = function() {
$routeSegment.chain[0].reload();
};
Other properties and methods available on $routeSegment
and the elements in the chain
array can be found here.