zoukankan      html  css  js  c++  java
  • ui-router ^1.x在ng1中使用state events

    官网信息:https://ui-router.github.io/ng1/docs/latest/modules/ng1_state_events.html

    Legacy state events

    Polyfill implementation of the UI-Router 0.2.x state events.

    The 0.2.x state events are deprecated. We recommend moving to Transition Hooks instead, as they provide much more flexibility, support async, and provide the context (the Transition, etc) necessary to implement meaningful application behaviors.

    To enable these state events, include thestateEvents.jsfile in your project, e.g.,

    <script src="stateEvents.js"></script>
    

    and also make sure you depend on theui.router.state.eventsangular module, e.g.,

    angular.module("myApplication", ['ui.router', 'ui.router.state.events']

    ---------------------------------------------------------------------------------------------------
    已知UI-Router在0.2.x中的state events在
    UI-Router1.x中被弃用,所以一定要手动引入stateEvents.js以及注入'ui.router.state.events';在于gulp构建的项目中:bower.json的"overrides"对向下添加

    "angular-ui-router": {
        "main": [
            "release/angular-ui-router.js",
            "release/stateEvents.min.js"
        ]
    };

    接着在app.run.json中就可以直接使用'$stateChangeStart'

    =》

    'use strict';
    angular.module("myApp")
        .run(['$rootScope', '$state','$location', function ($rootScope, $state, $location) {
            $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
            console.log(toParams.t)
            console.log(toParams.c)
            $rootScope.accessToken = toParams.t
            $rootScope.clientId = toParams.c
         })
    }])

    原创;转载请标注!

  • 相关阅读:
    在下拉框中选择数据
    代码添加批处理类
    重置用户状态(初始化用户)
    当前窗口控制(显示、隐藏、破坏)
    窗体分隔符实现
    使用USB移动硬盘 遭遇 "Windows无法为Volume加载安装程序。请于硬件供应商联系,寻求协助" 错误,“灰鸽子”后遗症的处理
    使用IDL创建TypeLib(.tlb)文件
    ngrep使用方法
    常用的正则表达式
    治疗鼻炎的药
  • 原文地址:https://www.cnblogs.com/edison1412/p/7248631.html
Copyright © 2011-2022 走看看