• ionic不同view跳转到同一个


    ionic不同view跳转到同一个 view并保留历史的路由设计

    上代码:state 里面新加一个状态

    .state("other", {
        url: "/other",
        abstract: true,
        controller: "OtherCtrl",
        template: "<ion-nav-view></ion-nav-view>",
        onEnter: function($rootScope, fromStateServ) {
            fromStateServ.setState("other", $rootScope.fromState, $rootScope.fromParams);
        }
    })


    对应的controller
    .controller("OtherCtrl", function($scope, $state, fromStateServ) {
        $scope.backNav = function() {
            var fromState = fromStateServ.getState("other");
            if (fromState.fromState !== undefined) {
                $state.go(fromState.fromState.name, fromState.fromParams);
            } else {
                //设置没有历史的时候,默认的跳转
                $state.go("app.xxx");
            }
        };
    })

    保留 history 的公共方法
    .factory("fromStateServ", function() {
        return {
            data: {},
            setState: function(module, fromState, fromParams) {
                this.data[module] = {
                    "fromState": fromState,
                    "fromParams": fromParams
                };
            },
            getState: function(module) {
                return this.data[module];
            }
        };
    })

    https://segmentfault.com/n/1330000004202748

  • 相关阅读:
    Log4Net记录到MySql
    创建快照
    grep的用法(CentOS7)及有关正则表达式的使用
    samba
    mkdir
    raid0和raid5的 实验过程
    route
    source和sh执行脚本时的差异
    echo命令的简单用法和实例
    smbpasswd和pdbedit
  • 原文地址:https://www.cnblogs.com/xqschool/p/6033396.html
Copyright © 2020-2023  润新知