Home  >  Q&A  >  body text

angular.js - Angular和express的路由是怎么回事?高手大大看看吧

现在做了一个应用,都是纯后端提供数据。所以用了angular的路由,现在要导出excel。我想用nodejs去取得路由,然后做功能。现在是angular的路由感觉不跟express一样

var http = require('http');
var url = require("url");
var express = require('express');
var app = express();

app.use(express.static(__dirname+'/app'));  //所有的静态页面和资源

app.use(function(req,res,next){
    console.log(123);
    next();
})
http.createServer(app).listen(3000, function(){
    console.log('Server start at port 3000')
})

现在123是打印不出来,因为路由都在前端的angular。怎么做啊,救命啊。。。。

PHP中文网PHP中文网2714 days ago635

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 16:51:15

    You haven’t written the route yet. What connection do you want to access?

    For example get root directory /

    Add the following methods:

    app.get('/', function(req,res,next){
        console.log(123);
        next();
    })
    

    Then visit with your browser:
    localhost:3000

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-15 16:51:15

    Node cannot get Angular’s ​​route. Angular does it on the client side. You can get it from location.hash and submit it to the backend

    reply
    0
  • Cancelreply