大佬教程收集整理的这篇文章主要介绍了angularjs – Angular UI路由器刷新时的动态状态变为404,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法在点击刷新按钮之前进入状态?我应该在按下刷新之前存储状态然后使用它吗?
.state('404',{ url: '/404',templateUrl: '404.tmpl.html',controller: function ($scope,$state,APP) { $scope.app = APP; $scope.goHome = function () { $state.go('default.page'); }; } }) $urlRouterProvider.otherwise('/404');
….
$rootScope.$on('$stateChangeStart',function (e,toState,toParams,fromState,fromParams) { //fromState.name = '' on refresh });
提前致谢!
.run(function ($rootScope,$window,authService,$http,$timeout,localStorageService) { $rootScope.$on('$stateChangeStart',fromParams) { if (authService.isLoggedIn()) { if (toState.name === "404" && fromState.name === '' && localStorageService.get("LAST_STATE") !== "404") { authService.loadStates($stateProviderRef).then(function () { $state.go(localStorageService.get("LAST_STATE"),localStorageService.get("LAST_STATE_PARAMS")); }); } } }); window.onbeforeunload = function () { localStorageService.set("LAST_STATE",$state.current.name); localStorageService.set("LAST_STATE_PARAMS",$state.params); return null; } })
以上是大佬教程为你收集整理的angularjs – Angular UI路由器刷新时的动态状态变为404全部内容,希望文章能够帮你解决angularjs – Angular UI路由器刷新时的动态状态变为404所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。