0

I am using Angular's UI Router and I am looking to create a $scope function (ultimately to pass to the view to have a ng-click call it) to reload a controller and its associated resolver. How would I do this?

I've tried this but it doesn't seem to reload the resolver:

$scope.reloadMe = function() {
    $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: true });
};

2 Answers 2

1

just inject $route into the controller and call $route.reload so the code would look like:

$scope.reloadMe = function () {
  $route.reload();
};

You can read the documentation here: https://docs.angularjs.org/api/ngRoute/service/$route

Sign up to request clarification or add additional context in comments.

Comments

0

You can inject $injector and load $state to reload. Here I put two examples, you can use one of them.

function MyController($injector, data) {
    $injector.get('$state').reload(); // this reload all states and controllers scopes
    // or
    $injector.get('$state').go($state.current, {}, {reload: true}); // second parameter is for $stateParams
}

Otherwise, in case i need to reload the page, i use javascript

window.location.reload() 

This question is asked here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.