小编bib*_*rno的帖子

如何强制Angular在HTML5模式下向服务器发送请求?

我正在使用angular和nodejs构建和web.我/home在/包含登录和注册表单的路径上加载Angular .这是我的角度配置:

window.app.config(['$routeProvider', '$locationProvider',
    function($routeProvider,$locationProvider) {
        $locationProvider.html5Mode(true);
        $locationProvider.hashPrefix('!');
        $routeProvider.
        when('/profile', {
            templateUrl: '/views/account.html',

        }).
        when('/edit', {
            templateUrl: '/views/edit.html',

        }).
        when('/home', {
            templateUrl: 'views/index.html'
        }).
        when('/signout', {
            templateUrl: 'views/signout.html'
            //on this view i load a controller which submits a form to /signout
        }).

        otherwise({
            redirectTo: '/home'
        });
    }
]);
Run Code Online (Sandbox Code Playgroud)

在服务器端路由:

    app.get('/',function(){
          res.render('index',{
             user: req.user? req.user:'guest'
        });
    });
    app.post('/login',function(){
             //if success redirect to /home
             //if fails redirect to /
    });
    app.get('/auth/facebook', passport.authenticate('facebook', { scope: [ 'email',                  'user_about_me', 'read_stream', …
Run Code Online (Sandbox Code Playgroud)

oauth node.js oauth-2.0 angularjs angular-routing

5
推荐指数
1
解决办法
1815
查看次数

标签 统计

angular-routing ×1

angularjs ×1

node.js ×1

oauth ×1

oauth-2.0 ×1