小编glo*_*log的帖子

快递路由器 - :id?

真正简单的问题:我看到很多书籍/代码片段在路由器中使用以下语法:

app.use('/todos/:id', function (req, res, next) {
  console.log('Request Type:', req.method);
  next();
});
Run Code Online (Sandbox Code Playgroud)

我不确定如何解释这里的路线......它会路由'/ todos/anything'吗?然后抓住'任何'并且处理变量ID?我该如何使用该变量?我确信这是一个快速的答案,我之前没有看到过这种语法.

node.js express

21
推荐指数
2
解决办法
2万
查看次数

"TypeError:无法读取属性'apply'of undefined"

使用node,express,socket.io,jade和angular.得到错误:TypeError: Cannot read property 'apply' of undefined.有什么建议?

index.js:

module.exports = function(app, res) {
  res.render('index', { title: 'Express' });
  var io = app.get('io');
  io.on('connection', function(socket){
  });
};
Run Code Online (Sandbox Code Playgroud)

index.jade:

extends layout

block content

script.
    var app = angular.module('hackigur', []);
    var socket = io.connect();
    var refreshTimer = 10;

    app.controller('UpdateController', function($scope){
        //socket.on('update', function(msg){
            //$scope.refreshTimer = msg;
            //$scope.$apply();
        //});

        setInterval(secondTick,1000);

        function secondTick() {
            if(refreshTimer != 0) {
                refreshTimer -= 1;
            }
            $scope.refreshTimer = refreshTimer;
            $scope.$apply();
        };
    });

h1= title
p Welcome to #{title} …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express angularjs

10
推荐指数
1
解决办法
5万
查看次数

标签 统计

express ×2

node.js ×2

angularjs ×1

javascript ×1