var app = angular.module('wechat', ['ngRoute']);

app.constant('config', {
    rootPath: '/assets/wechat/',
    rootUrl: '/',
    apiUrl: '/api/v1/'
});


app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){

    if(g_redirect_path && g_redirect_path.length>1){
        $location.path(g_redirect_path);
        g_redirect_path = null;
    }

    $rootScope.$on('$routeChangeError', function(event, next, current){

        if(next && next.templateUrl){
            if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){
                $location.path("/login");
            }
        }
    });

    $rootScope.$on('$routeChangeStart', function(event, next, current){
    });
}
]);