从node.js中以angularjs的forms使用json数据作为后端和sql数据库
我正在devise一个简单的应用程序,它在后端有一个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中的获取请求:
$http.get('/api/views/123').success(function(data,status,headers,config){ }). error(function(data,status,headers,config){ });
我想知道如何在angularjs中使用JSON数据,并希望json数据以angularjs显示。
这并不难。 从服务器接收的data
存储在callback函数内的data
variables中:
$http.get('/api/views/123').success(function(data,status,headers,config){ console.log(data) //--> logs out the data to the console })