angularjs - 访问 GET 参数

标签 angularjs node.js

我想发送我的 server.js(在 AngularJS Controller 中)并像这样设置 id 参数:

 $http
    .get('/getCst', {
        params: {               
            id: customerID
        }
     })
     .success(function (data,status) {
          $scope.customer = data
     });

但我不确定这是否是正确的方式以及在 Node.js server.js 中应该写些什么:

app.get('/getCst', function (req, res) {

        console.log(//how do i get the id sent by the client?);     
});

最佳答案

这是我的解决方案

app.get('/getCst/:id', function (req, res, next) {

        var id = req.params.id;    
});

关于angularjs - 访问 GET 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27918577/

相关文章:

angularjs - 如何在 AngularJS 的 View 中嵌套表达式?

node.js - Node.js Heroku 应用程序上的 TCP 连接

node.js - Angular 9 通用引用错误 : window is not defined

node.js - `express` 应用程序 - 无法使用 `post` 测试 `postman` 请求

javascript - MongoDB 通过查找查询随机选择 5 个文档

node.js - 如何在azure应用程序服务上调试nodejs应用程序 - 获取http状态代码500

javascript - 如何在我的 Angular 代码中使用 angular-sortable-view?

javascript - 在 AngularJS 中单击更改 div 背景颜色

javascript - Angular JS 动画不工作

AngularJS - 如何公开服务属性