AngularJS $route service reload() method is useful when you want to reload just the current route instead of the entire application.
By using the route service reload() method we can achieve the same with only one single request instead of the whole bunch of data to be reload. The below code fragment will let you understand that how to use the reload() method of $route service of AngularJS .
for example in my angular app we have a controller named membersController, which actually fetch the data from the web service with the help of $http service of AngularJS . To use the $route service reload method, inject $route service into your controller and call the reload() method of the service.
// Controller Code
.controller("membersController", function($http, $route)
{
var viewModel = this;
viewModel.reloadData = function()
{
$route.reload();
}
$http.get("MemberService.asmx/GetAllMembers")
.then(function(response)
{
viewModel.members = response.data;
})
// now the reloadData property is available to the controller and we can use this property in HTML view using below code snippet.
<!-- HTML View -->
//Create a button which calls the reloadData() method onclick event
<
button ng - click = "membersController.reloadData()" > Reload Data < /button>
Now insert a record into your table and then click on the Reload Data button on HTML View. Goto the Developer tool --> Network section and see how less is data transferred between request response cycle.