简体   繁体   English

重新加载AngularJS页面的最佳实践是什么

[英]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.

相关问题 重新加载页面后维护菜单的最佳做法是什么? 我有这个自定义代码,感觉不对 - What is the best practice for maintain a menu after a page reload? I have this custom code which feels wrong 在给定的工作流程中,angularjs和指令的最佳实践是什么? - What is the best practice for angularjs and directives in the given workflow? AngularJS中多个$ http请求的最佳实践是什么? - What is the best practice for multiple $http request in AngularJS? 使用webpack导入angularjs的最佳做法是什么? - What is the best practice for importing angularjs using webpack? 在页面上使用SVG的最佳实践是什么? - What is best practice to use SVG on page? Angularjs 缩小最佳实践 - Angularjs minify best practice AngularJS过滤器最佳实践 - AngularJS Filter Best Practice 在AngularJS中处理应用程序状态和事件广播的最佳实践是什么? - What's the best practice for dealing with application states and event broadcasting in AngularJS? AngularJS:以编程方式将ngIf添加到指令的最佳做法是什么? - AngularJS: What's the best practice to add ngIf to a directive programmatically? AngularJS:在组件之间进行通信的最佳实践是什么? - AngularJS: What is the best practice to make communication between components?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM