角 - UI路由器 - 状态重入 [英] Angular - UI Router - state reentrance

查看:114
本文介绍了角 - UI路由器 - 状态重入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置用户界面路由器重新输入或默认?重载状态

例如。用户要刷新页面,所以他点击下面到该页面的链接。但是目前链接无法点击,因为它去到相同的页面和状态不会改变。用浏览器按钮,刷新不工作,所以它再重新加载整个SPA - 是不可取的。

E.g. user wants to refresh page, so he clicks the link that follows to that page. But currently the link isn't clickable, as it goes to the same page and the state doesn't change. Refreshing with browser button does work, so it reloads entire SPA again - isn't desirable.

这个问题 - <一个href=\"http://stackoverflow.com/questions/21714655/angular-js-angular-ui-router-reloading-current-state-refresh-data\">Angular JS - 角UI路由器 - 重装当前状态 - 刷新数据 - 描述了类似的效果。是否有可能改变这种解决方案 - http://stackoverflow.com/a/23198743/404099 - 定义默认行为?

This question - Angular JS - Angular UI Router - Reloading current state - refresh data - describes similar effect. Is it possible to change this solution - http://stackoverflow.com/a/23198743/404099 - to define the default behavior?

顺便说一句,也许我的做法是不正确的,我错过在UI路由器的一些基本概念。请指出,如果是这样的话。

By the way, probably my approach is incorrect and I'm missing some basic idea in UI Router. Please point out if this is the case.

推荐答案

我第二什么@Sabacc说,但如果你还是相反,在这里你去:

I second what @Sabacc said, but if you still instead, here you go:

angular.module('app')
.config(function($provide) {
    $provide.decorator('$state', function($delegate)
    {
        $delegate.go = function(to, params, options)
        {
            return $delegate.transitionTo(to, params, angular.extend(
            {
                reload: true,
                inherit: true,
                relative: $delegate.$current
            }, options));
        };
        return $delegate;
    });
});

这篇关于角 - UI路由器 - 状态重入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆