search

Home  >  Q&A  >  body text

node.js - nodejs 与 angularjs 数据交互

问大家一个问题,nodejs 与 angularjs 如何实现数据交互,如何把前台的数据通过angularjs 发送到后台,后台如何返回数据到angularjs 呢??

谢谢大家的回答,我现在不知道如何部署到服务器里,如何才能让大家访问到我的angularjs页面,呢

巴扎黑巴扎黑2784 days ago612

reply all(8)I'll reply

  • 迷茫

    迷茫2017-04-17 11:42:42

    https://github.com/btford/angular-express-seed

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:42:42

    Same, it doesn’t matter whether the backend is node or not, you just need to use angular’s ​​$http service to send an ajax request; the backend will handle it. In addition, angular also supports using $resource to interact with RESTful server data sources

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:42:42

    It seems to be using the $http command in angulajs

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:42:42

    Node is on the server side and is responsible for providing API; Angular is on the client side and uses the $http service to send ajax requests and interact with the API for data

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:42:42

    XXX interacts with angularjs data

    The answer should be the same

    Usually use $http or $resource of angularjs to obtain

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:42:42

    In fact, the main idea is to use ajax requests to process the data returned after success or failure.

    In angular, you can use the $http.get() method:

    $http.get().success(function(date){
        // deal data...
    })
    

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:42:42

    This problem has nothing to do with nodejs;
    How to interact with data in a non-nodejs environment is the same under nodejs. It is transparent to your front end (angularjs implementation)

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:42:42

    I have a similar problem!
    It’s no problem to get it through angular, this is pull mode!
    You configure app.get render in app.js to index.html and use $http.get() to get it. I should have sent two requests!

    If you bring the required data to the controller in node render, you don’t need to send an asynchronous request!

    Is that so?
    The following code was found online

    // employeeService.queryData(function(data) {
        //   var v = _.clone(mapping.employeeList);
        //   v.list = data;
    
        //   console.log( v );
        //   console.log( "==============" );
        //   res.render(mapping.employeeList.view, v);
        // });
        
    employeeService 是什么鬼但不到!
    

    reply
    0
  • Cancelreply