这两者的区别:请看博客:http://stackoverflow.com/questions/32680292/angularjs-state-and-rootscope-onstatechangestart-issue

使用方法:

在config方法里注册:
$urlRouterProvider.otherwise( function($injector, $location) {
var $state = $injector.get("$state");
$state.go("cover");
}); $stateProvider
.state('auth', {
url: '/auth',
templateUrl: '../views/authView.html',
controller: 'AuthController as auth'
})
.state('users', {
url: '/users',
templateUrl: '../views/userView.html',
controller: 'UserController as user'
})
....
app.run(function($rootScope, $state, $location) {
$rootScope.$on('$stateChangeStart', function(event, toState, fromState) { //ERROR IS IN THIS BLOCK
if($rootScope.authenticated && $rootScope.onboard == ) { //event.preventDefault(); $state.transitionTo("onboard", null, {notify:false});
$state.go('onboard');
}
...

随机推荐

  1. Python爬虫基础(四)Requests库的使用

    requests文档 首先需要安装:pip install requests get请求 最基本的get: # -*- coding: utf-8 -*-import requests respons ...

  2. 系统中同时有 python2和 python3,怎么让 ipython 选择不同的版本启动?

    已经安装的情况下: > which ipython /usr/local/bin/ipython > cat /usr/local/bin/ipython  #!/usr/local/op ...

  3. Kubernetes实战(二):k8s v1.11.1 prometheus traefik组件安装及集群测试

    1.traefik traefik:HTTP层路由,官网:http://traefik.cn/,文档:https://docs.traefik.io/user-guide/kubernetes/ 功能 ...

  4. sipp保持sip协议的tcp长连接

    sipp这个工具非常有用,但是由于应用手册不完善,加上资料非常少,所以要用熟练是非常不容易的.

  5. 【PGM】Representation--Knowledge Engineering,不同的模型表示,变量的类型,structure & parameters

    Part 1. 重要的区别: Template based   vs.   specific Directed  vs.  undirected Generative  vs.  discrimina ...

  6. jquery map方法使用示例

    jquery的map方法非常好用,其作用是将数组或单个对象,替换为新的内容 感觉jquery的map方法非常好用. 方法作用:将数组或单个对象,替换为新的内容.  应用实例:获取一组checkbox的 ...

  7. redhat 5 samba配置

    1.检查安装包 #rpm –qa | grep samba 必须有以下安装结果 samba-3.0.25:samba-common-3.0.25:samba-client-3.0.25:samba-s ...

  8. lvs原理及各种调度算法详解

    LVS原理详解 LVS原理详解 LVS简介 LVS结构与工作原理 一.LVS的结构 二.LVS内核模型 三.LVS的包转发模型 1.NAT模型: 2.DR模型: 3.TUN模型: 四.LVS的调度算法 ...

  9. 手把手教你学node.js之学习使用外部模块

    学习使用外部模块 目标 建立一个 lesson2 项目,在其中编写代码. 当在浏览器中访问 http://localhost:3000/?q=alsotang 时,输出 alsotang 的 md5 ...

  10. 已有模板与tp框架的结合 (前台)

    已有模板与tp框架的结合 具体步骤   A.复制模板文件到view指定目录 B. 复合css .js.img.静态资源文件到系统指定目录 C. 把静态资源(css,js,img)文件的路径设置为“常量 ...