[英]what is the best practice to reload AngularJS page
I need to know what is best practice to work with Auth Service and authInterceptor Service 我需要知道与Auth Service和authInterceptor Service一起使用的最佳实践
$window.location.reload();
$scope.$apply();
$location.path('/');
I have used this in my application to rerender the data.if you are in the same state as well you will be able to rerender the data. 我已经在我的应用程序中使用过此功能来重新渲染数据。如果您也处于相同状态,则可以重新渲染数据。
$state.transitionTo('app.emp.nav.portfolio', null, {'reload':true});
Using $location.path('/')
in some cases could be useless because AngularJS won't refresh the controller if location doesn't change. 在某些情况下使用
$location.path('/')
可能没有用,因为如果位置不变,AngularJS不会刷新控制器。
You should try to use this statement to re-render the page 您应该尝试使用此语句重新呈现页面
$route.reload();
Remember to inject $route
in your controller. 请记住在控制器中注入
$route
。
Also you can see AngularJS documentation about this: AngularJS: API: $route 您也可以查看有关以下内容的AngularJS文档: AngularJS:API:$ route
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.