$state和$rootScope.$on($stateChangeStart)
这两者的区别:请看博客: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');
}
...
随机推荐
- AIX系统崩溃后oracle数据库的恢复方法
首先要确保数据库实例的完整性,包括控制文件,日志文件,表空间(系统表空间.用户表空间等). 新建同名数据库实例(表空间.用户等不需要). Sql>shutdown immediate关闭数据库 ...
- 青岛网络赛J-Press the button【暴力】
Press the Button Time Limit: 1 Second Memory Limit: 131072 KB BaoBao and DreamGrid are playing ...
- The Rise of Database Sharding DATABASE SHARDING
w玻璃碎片.0共享 http://www.agildata.com/database-sharding/ The Rise of Database Sharding The concept of Da ...
- the source attachment does not contain the source for the file xxx.class无法关联到某个类
问题描述: 按下列操作添加相应路径(这里是错误操作) 该问题仍旧无法解决: 注意:这里spring-webmvc-4.1.7.RELEASE.JAR中确实包含AnntationMethodHandle ...
- 【Javascript】Windows下Node.js与npm的安装与配置
1:先下载Node.js,网站https://nodejs.org/en/,左侧为稳定版,右侧为最新版,推荐稳定版 2:Node.js安装,运行下载后的.msi文件,一路下一步就可以了,我选择的安 ...
- java-mybaits-00801-逆向工程
1.1 什么是逆向工程 参看地址:http://www.mybatis.org/generator/index.html 使用官方网站的mapper自动生成工具mybatis-generato ...
- [转] Delphi Socket Architecture
Delphi Socket Architecture - Felix John COLIBRI. abstract : The architecture of the ScktComp socket ...
- 主从同步DNS(BIND)
看着别人搭建很简单,其实到自己做的时候需要考虑更多的问题. 1.环境 1)操作系统最好一样,配置一样 2)关闭防火墙,selinux,时间要同步(我就是用的纽约的时区,同步中国的时间,虽然时间是相同的 ...
- C# 使用 wkhtmltopdf 把HTML文本或文件转换为PDF
一.简介 之前也记录过一篇关于把 HTML 文本或 HTML 文件转换为 PDF 的博客,只是之前那种方法有些局限性. 后来又了解到 wkhtmltopdf.exe 这个工具,这个工具比起之前的那种方 ...
- Educational Codeforces Round 58 Solution
A. Minimum Integer 签到. #include <bits/stdc++.h> using namespace std; #define ll long long ll l ...