从NodeJS检索数据时,未使用AngularJS显示输出 [英] Output is not being shown using AngularJS when data is retrieved from NodeJS
本文介绍了从NodeJS检索数据时,未使用AngularJS显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我使用NodeJS的后端代码,我正试图通过该代码发送JSON数据. -
Here is my back end code using NodeJS, by which I am trying to send JSON data. -
con.query(sql, function(err, result, fields){
if(err) throw err;
res.setHeader('Content-Type', 'application/json');
var Dict = {"records":result};
res.end(JSON.stringify(Dict));
});
这是我使用AngularJS的前端代码,通过它我试图在浏览器上显示JSON数据-
Here is my front end code using AngularJS, by which I am trying to show JSON data on the browser-
<body>
<div ng-app='myApp' ng-controller="MyCtrl">
<p ng-model="rows">
{{ rows }}
</p>
</div>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl', function($scope,$http){
$http.get("http://localhost:1208").then(function(response){
$scope.rows = response.data.records;
});
});
</script>
</body>
但是当我在浏览器中运行此Angularjs文件代码时,它什么也没有显示.谁能帮我解决这个问题?我想在浏览器上显示我的JSON数据.
But when I run this Angularjs file code on the browser, it shows nothing. Can anyone help me to fix this problem? I wanna show my JSON data on the browser.
推荐答案
不是输入元素,并且没有 ng-model
标记
is not an input element and it does not have ng-model
tag,
删除并更改为
<p>
{{ rows }}
</p>
这篇关于从NodeJS检索数据时,未使用AngularJS显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文