9951 explained code solutions for 126 technologies

angularjsHow do I reload a component in AngularJS?

To reload a component in AngularJS, you can use the $route.reload() method. This will reload the current active route, causing any associated controller to be executed again.

For example:

angular.module('myApp', ['ngRoute'])
  .controller('MyController', function($scope, $route) {
    $scope.reloadRoute = function() {

The above code will reload the current active route when the reloadRoute function is called.

The $route.reload() method has the following parts:

  • $route: The AngularJS service that provides access to the current route.
  • reload(): The method that reloads the current active route.

For more information, see the AngularJS $route Documentation.

Edit this code on GitHub