首页 > 其他 > 详细

angular-route 和soket注意细节点

时间:2016-03-08 18:02:43      阅读:192      评论:0      收藏:0      [点我收藏+]

route run 文件是第一个位置,之后才配置路由哪些,代码:

angular.module(‘technodeApp‘,[‘ngRoute‘]).run(function($window,$rootScope,$http,$location){
$http({
url:‘/api/validate‘,
method:‘GET‘
}).success(function(user){
$rootScope.me = user;
$location.path(‘/‘);
}).error(function(data){
$location.path(‘/login‘);
});
$rootScope.logout = function(){
$http({
url:‘api/logout‘,
method:‘get‘
}).success(function(){
$rootScope.me = null;
$location.path(‘/login‘);
});

};
$rootScope.$on(‘login‘,function(evt,me){
$rootScope.me = me;
});
});;
angular.module(‘technodeApp‘).config(function($routeProvider){
$routeProvider.when(‘/‘,{
templateUrl:‘/pages/room.html‘,
controller:‘RoomCtrl‘
}).when(‘/login‘,{
templateUrl:‘/pages/login.html‘,
controller:‘LoginCtrl‘
}).otherwise({redirectTo:‘/login‘});
});

还有html5 模式会报错,去了。

另外 soket io 获取cookie 要改成 var hrjson = cookieParser.signedCookies(cookie.parse(decodeURIComponent(handshakeData.headers.cookie)),‘technode‘);

妹的,足足研究了我大半个月。

angular-route 和soket注意细节点

原文:http://www.cnblogs.com/starzhan/p/5254866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!