search

Home  >  Q&A  >  body text

angular.js - What's going on with Angular and express routing? Experts, let’s take a look

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中文网2775 days ago687

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