这两者的区别:请看博客: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. 最短路和次短路的条数(dijstra算法或spfa算法)POJ3463

    http://poj.org/problem?id=3463 Sightseeing Time Limit: 2000MS   Memory Limit: 65536K Total Submissio ...

  2. 微信开发(3):微信公众号发现金红包功能开发,利用第三方SDK实现(转)

    最近需求是 用户兑换微信红包,需要一些验证,加密,以及证书: 工欲善其事必先利其器 感谢前辈的微信SDK 已经维护三年了,还在维护中! 官方文档走一波 文档还是一如既往的 坑人啊,写的很简单,对简单明 ...

  3. docker :no such file or directory

    ---恢复内容开始--- 其中最主要的问题是:details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: ...

  4. [ASP.NET]从Request.Url获取根网址的最简单方法

    在拼接绝对路径的网址时,经常需要从Request.Url中获取根网址(比如http://www.cnblogs.com),然后与相对路径一起拼接为绝对路径. 以前的做法如下: var uri = Re ...

  5. SQL---->mySQl安装for mac

    我安装是参考如下两篇博客,但是有些不同,这里写好参考来源: http://blog.csdn.net/li_huifeng/article/details/9449685 http://www.jia ...

  6. uboot ping doesn’t work

    Ping doesn't work Ping from U-Boot to a host should work. Ping from a host to U-Boot should not. U-B ...

  7. What are Traceroute, Ping, Telnet and Nslookup commands?

    https://help.maximumasp.com/KB/a445/connectivity-testing-with-ping-telnet-tracert-and-pathping-.aspx ...

  8. cookie.setPath()的用法

    正常的cookie只能在一个应用中共享,即:一个cookie只能由创建它的应用获得. 可在同一应用服务器内共享cookie的方法:设置cookie.setPath("/");  ( ...

  9. Nginx反向代理服务器安装与配置

    一.服务器安装: sudo yum install gcc-c++ sudo yum install pcre pcre-devel sudo yum install zlib zlib-devel ...

  10. centos 配置mysql

    1.在线安装 1.首先检测一下,mysql之前有没有被安装 命令:rpm -qa | grep mysql 2.删除mysql的命令: rpm -e --nodeps `rpm -qa | grep ...