更改状态时防止状态重新加载ui-router
问题描述:
我知道这已被问及在多个帖子中回答,但我已尝试解决方案,仍然不能完全到达那里呢。更改状态时防止状态重新加载ui-router
我有几个组件与ui-router进行路由,一个是联系表单,如果用户输入数据并移动到另一个路由,然后返回到联系表单,状态将重新加载并且表单内容消失了。
我saw通过拥有父状态和子状态,但不能在我的代码中重新创建此操作的另一种方法。
也许有一个更简单的解决方案,使用ui-router-extras与粘性选项,虽然我尝试了这一点,也无法让它工作。我现在将发布代码。
(function() {
angular.module('personalPortfolio')
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('about', {
sticky: true,
url: '/about',
template: '<pg-about></pg-about>'
})
.state('development', {
sticky: true,
url: '/work',
template: '<pg-dev></pg-dev>'
})
.state('contact', {
sticky: true,
url: '/contact',
template: '<pg-contact></pg-contact>'
});
$urlRouterProvider.otherwise('/about');
}]);
})();
答
您可以在存储未保存的表单数据时创建服务。
这将工作,虽然它不适合,因为我也有另一个页面,提取一些数据,我只希望通过浏览器按钮完全刷新刷新数据。 – okayilltry