angular.js - Angular和express的路由是怎么回事?高手大大看看吧
PHP中文网
PHP中文网 2017-05-15 16:49:15
0
2
670

现在做了一个应用,都是纯后端提供数据。所以用了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中文网

认证高级PHP讲师

reply all(2)
洪涛

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

过去多啦不再A梦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template