AngularJs路由,服务器中的多个请求

时间:2015-03-06 20:40:02

标签: angularjs node.js express

我想使用angularjs路由,我正在使用它,但它在服务器端发出了额外的请求。任何人都知道这个问题的解决方案,或者我做错了什么?

客户端app.js

app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    $locationProvider.html5Mode({enabled: true, requireBase: false})
    $routeProvider.
        when('/', {
            templateUrl: '/tpl/main.tmp.html',
            controller: 'MainCtrl'
        })
        .otherwise({redirectTo: '/'})
}])

//routes.js
app.get('/', function(req, res) {
    console.log("test")
    res.render(__dirname+'/public/tpl/index.html', siteConfig)
})
//output
//test
//test
//test
//test

文件:

models
public
|-css
|-js
|--app.js
|--angular.js
app.js

1 个答案:

答案 0 :(得分:0)

有些事情可能会导致这种情况,仔细检查两个请求数据包可能会缩小原因。要检查的一些想法: