[英]How to show json data in a table format retrieved from node.js server using Angular Js
This is an index file I had made to display the json data though angular.js 这是我制作的一个索引文件,用于通过angular.js显示json数据
<!DOCTYPE html>
<html>
<head>
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
</style>
<script src= “http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js”></script>
</head>
<body>
<div ng-app=”” ng-controller=”blogController”>
<table>
<tr><td>Manger Id</td><td>Manger Name</td></tr>
<tr ng-repeat=”x in name”>
<td>{{ x.m_id }}</td>
<td>{{ x.name }}</td>
</tr>
</table>
</div>
<script>
function blogController($scope,$http) {
$http.get('http://localhost:3000/techgeek/v1/getEmployeeDetails')
.success(function(response) {
$scope.names = response;
console.log($scope.names);
});
}
</script>
</body>
</html>
I am unable to get the json data from nodejs server. 我无法从nodejs服务器获取json数据。 I aslo attacted a secreen shout my json data genereated though nodejs sever .
我还通过nodejs切断了对我的json数据的保密提示。
.
。 The main problem with url.
网址的主要问题。 Thanks for your help in advance
谢谢您的帮助
Here is the live for your problem. 这是为您解决的问题。 I have solved it using the local Json.
我已经使用本地Json解决了它。 You have made the following mistakes as below
您犯了以下错误:
<tr><td>Manger Id</td><td>Manger Name</td></tr>
<tr ng-repeat="x in names track by $index">
<td>{{ x.m_id }}</td>
<td>{{ x.m_name }}</td>
</tr>
You have a problem with the module as you have used ng-app=""
in your code please fix it by using a module as below 您的模块有问题,因为您在代码中使用了
ng-app=""
,请使用以下模块进行修复
var app = angular.module('plunker', []);
app.controller("",function(){
.....................
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.