I'm trying to reload page using $route.reload()
:
var App = angular.module("App", ["ngRoute"]);
var idx = 0;
App.controller("List", function ($scope, $route) {
$scope.changeWallet = function (index) {
idx = index;
$route.reload();
console.log("success");
};
}
"success"
is shown in console, but nothing happens.
How can I fix this?
I'm trying to reload page using $route.reload()
:
var App = angular.module("App", ["ngRoute"]);
var idx = 0;
App.controller("List", function ($scope, $route) {
$scope.changeWallet = function (index) {
idx = index;
$route.reload();
console.log("success");
};
}
"success"
is shown in console, but nothing happens.
How can I fix this?
- Are you using ui-router ? – Satyam Koyani Commented Jun 2, 2014 at 8:42
- So Do you want to refresh template only ? – Satyam Koyani Commented Jun 2, 2014 at 8:44
- Remove template from cache first then try to reload the template.add this "var currentPageTemplate = $route.current.templateUrl; $templateCache.remove(currentPageTemplate);" before reload function call. – Satyam Koyani Commented Jun 2, 2014 at 8:48
-
I got
undefined is not an object (evaluating '$route.current.templateUrl')
– supertrall Commented Jun 2, 2014 at 8:56 - I don't believe it is anything to do with template cache. @supertrall You you want to reload the view partial or the plete page? – Chandermani Commented Jun 2, 2014 at 8:57
2 Answers
Reset to default 10If you want to reload the plete page instead of route refresh inject the $window
service and call location.refresh
$window.location.reload();
The $window.location.reload() will basically refresh the page like when you're pressing F5 for refresh.
What I am after is reload the specific views in the page not refreshing the entire page.