filmov
tv
AngularJS Route Reload

Показать описание
In this video we will discuss angular route service reload() method. This method is useful when you want to reload just the current route instead of the entire app. Let us understand this with an example.
One of the ways to see the new data is by clicking on the browser refresh button. The downside of this is that the entire app is reloaded. This means all the resources required to run your app will be reloaded. You can see all the resource requests made on the network tab in the browser developer tools.
The other way is to reload just the current route. Here are the steps.
.controller("studentsController", function ($http, $route) {
var vm = this;
}
.then(function (response) {
})
})
Please note :
1. $route service in injected in the controller function
2. reloadData() function is attached to the view model (vm) which will be available for the view to call. This method simply calls reload() method of the route service.
Removing angle brackets here while uploading this description which is not supporting for the below
h1List of Students/h1
ul
/a
/li
/ul
At this point
1. Run the app
3. Insert a new record in the database table
4. Open browser developer tools
5. Click the Reload button
There are 2 things to notice here
1. The newly added record will be shown on the view
2. Only the resources required to reload the current route are requested from the server
One of the ways to see the new data is by clicking on the browser refresh button. The downside of this is that the entire app is reloaded. This means all the resources required to run your app will be reloaded. You can see all the resource requests made on the network tab in the browser developer tools.
The other way is to reload just the current route. Here are the steps.
.controller("studentsController", function ($http, $route) {
var vm = this;
}
.then(function (response) {
})
})
Please note :
1. $route service in injected in the controller function
2. reloadData() function is attached to the view model (vm) which will be available for the view to call. This method simply calls reload() method of the route service.
Removing angle brackets here while uploading this description which is not supporting for the below
h1List of Students/h1
ul
/a
/li
/ul
At this point
1. Run the app
3. Insert a new record in the database table
4. Open browser developer tools
5. Click the Reload button
There are 2 things to notice here
1. The newly added record will be shown on the view
2. Only the resources required to reload the current route are requested from the server