angular js 路由加express 路由

app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);
//some code
app.get('/',function(req,res)..............
app.get('/api',function(req,res)..............

//最后再重定向到首页
app.all('/*',function(req,res){
      res.render('index')
}
同样在angular中也要设定html5模式:

app.config(function($locationProvider){
    $locationProvider.html5Mode(true);
        //$locationProvider.hashPrefix('!');这个我觉得没必要添加,#!
}

猜你喜欢

转载自a545807638.iteye.com/blog/2278027