gpt4 book ai didi

angularjs - 使用来自node.js的angularjs中的json数据作为后端和sql数据库

转载 作者:太空宇宙 更新时间:2023-11-03 22:12:16 25 4
gpt4 key购买 nike

我正在设计一个简单的应用程序,它在后端有node.js服务器,在前端有angularjs。我使用这样的代码进行简单的 GET 请求,以从 sqldb 获取一些信息:

req.execute('view_proc').then(function (recordsets) {
if (recordsets) {
res.write(JSON.stringify(recordsets));
console.log(recordsets);
result_send = {
is_logged: true,
};

我使用 json.stringify 将数据发送到 angularjs。以下是angularjs中的get请求:

$http.get('/api/views/123').success(function(data,status,headers,config){

}).
error(function(data,status,headers,config){

});

我想知道json数据如何在angularjs中使用,也希望json数据在angularjs中显示。

最佳答案

一点也不难。从服务器接收到的数据存储在回调函数内部的 data 变量中:

$http.get('/api/views/123').success(function(data,status,headers,config){
console.log(data) //--> logs out the data to the console
})

关于angularjs - 使用来自node.js的angularjs中的json数据作为后端和sql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38814712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com