大佬教程收集整理的这篇文章主要介绍了angularjs – UI-Router – 更改$状态,而不重新布局/重新加载页面,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我目前在页面/ schedule / 2/4/2014,我想进入编辑模式,当我单击按钮,并将uRL变为/计划/ 2/4/2014 /编辑。
我的编辑状态只是$ scope.isEdit = true,所以没有点重新加载整个页面。但是,我想要$状态和/或url更改,以便如果用户刷新页面,它开始在编辑模式。
我能做什么?
// updatED $stateProvider .state('schedules',{ url: "/schedules/:day/:month/:year",templateUrl: 'schedules.html',abstract: true,// make this abstract controller: function($scope,$state,$stateParams) { $scope.schedDate = moment($stateParams.year + '-' + $stateParams.month + '-' + $stateParams.day); $scope.isEdit = false; $scope.gotoEdit = function() { $scope.isEdit = true; $state.go('schedules.edit'); }; $scope.gotoView = function() { $scope.isEdit = false; $state.go('schedules.view'); }; },resolve: {...} }) .state('schedules.view',{ // added view mode url: "/view" }) .state('schedules.edit',{ // both children share controller above url: "/edit" });
一个重要的concept在这里是,在ui路由器,当应用程序在一个特定的状态 – 当一个状态是“活动” – 所有的祖先状态也是隐式活动。
所以,在这种情况下,
>当您的应用程序从视图模式进入编辑模式时,其父状态计划(连同其templateUrl,控制器甚至解析)仍将保留。>因为祖先状态是隐式激活的,即使子状态正在刷新(或直接从书签加载),页面仍将正确呈现。
以上是大佬教程为你收集整理的angularjs – UI-Router – 更改$状态,而不重新布局/重新加载页面全部内容,希望文章能够帮你解决angularjs – UI-Router – 更改$状态,而不重新布局/重新加载页面所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。