angular.js - What's going on with Angular and express routing? Experts, let's take a look
PHP中文网
PHP中文网 2017-05-15 16:49:15
0
2
695

Now I have made an application, which is pure backend to provide data. So I used angular routing and now I want to export to excel. I want to use nodejs to get routing and then do functions. Now Angular’s ​​routing doesn’t feel the same as 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')
})

Now 123 cannot be printed because the routing is in the front-end angular. What to do? Help. . . .

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