[英]What is the best practice for maintain a menu after a page reload? I have this custom code which feels wrong
[英]what is the best practice to reload AngularJS page
我需要知道與Auth Service和authInterceptor Service一起使用的最佳實踐
$window.location.reload();
$scope.$apply();
$location.path('/');
我已經在我的應用程序中使用過此功能來重新渲染數據。如果您也處於相同狀態,則可以重新渲染數據。 $state.transitionTo('app.emp.nav.portfolio', null, {'reload':true});
在某些情況下使用$location.path('/')
可能沒有用,因為如果位置不變,AngularJS不會刷新控制器。
您應該嘗試使用此語句重新呈現頁面
$route.reload();
請記住在控制器中注入$route
。
您也可以查看有關以下內容的AngularJS文檔: AngularJS:API:$ route
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.