• AngularJs 返回上一页


    html
      <script src="lib/angular/angular-1.4.9/angular.js"></script>
      <script src="lib/angular/angular-ui-router.min.js"></script>
    app
        angular.module('ConsoleUIApp', ['ui.router','ui.bootstrap'])
            .config(function ($stateProvider, $urlRouterProvider, $httpProvider) {
    
                // For any unmatched url, redirect to /state1
                $urlRouterProvider.otherwise("/home");
    
                $stateProvider
                    .state('home', {
                        url: "/home",
                        templateUrl: "views/home.html",
                        controller: 'HomeCtrl'
                    })
                    .state('testing', {
                        url: "/testing",
                        templateUrl: "views/testing.html",
                        controller: 'TestingCtrl'
                    })
            })
    
            .run(function($rootScope, growl, $state, $stateParams) {
                $rootScope.$state = $state;
                $rootScope.$stateParams = $stateParams;
                $rootScope.$on("$stateChangeSuccess",  function(event, toState, toParams, fromState, fromParams) {
                    // to be used for back button //won't work when page is reloaded.
                    $rootScope.previousState_name = fromState.name;
                    $rootScope.previousState_params = fromParams;
                });
                //back button function called from back button's ng-click="back()"
                $rootScope.back = function() {
                    $state.go($rootScope.previousState_name,$rootScope.previousState_params);
                };
            });
    controller:
        $scope.sub = function(addRode) {
        $rootScope.back()
        }

     网上复制的,from:https://code.csdn.net/snippets/1646410

  • 相关阅读:
    UML——六大关系整理
    C#编写Windows 服务
    Centos7下lamp环境搭建的小笔记
    awk命令分析日志的简单笔记
    ssrf小记
    关于cookie的一些学习笔记
    xssbypass小记
    xss挑战赛小记 0x03(xssgame)
    xss挑战赛小记 0x01(xsstest)
    ubuntu下安装LAMP环境遇到的一些小问题
  • 原文地址:https://www.cnblogs.com/already/p/5841525.html
Copyright © 2020-2023  润新知