【发布时间】:2016-03-10 08:55:07
【问题描述】:
我在控制器中有 json 数据作为响应。我必须在 html 中打印该数据。
为此我做了如下:
在我的控制器中
.controller('DataImportControl', ['$scope','$http', '$location', '$rootScope' , function($scope, $http, $location, $rootScope) {
console.log(" In dataimportCtrl");
$scope.readCustomer = function(){
console.log("in read customer");
$http.post('/custimport').success(function(response) {
console.log("in controller");
console.log("controller:"+response);
$scope.data=response;
}).error(function(response) {
console.error("error in posting");
});
};
}])
我的html代码:
<html>
<head>
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<div ng-app="" ng-controller="DataImportControl">
<form ng-submit="readCustomer()">
<button type="submit" >Submit</button>
</form>
<table class="table">
<thead>
<tr>
<th>Code exists in customer master</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="cust in data ">
<td>{{cust.customer_code}}</td>
</tr>
</tbody>
</table>
</div>
<div >
</div>
</body>
</html>
我的 json 数据作为控制器中的响应:
{"jarray":[{"customer_name":["Ankita"],"customer_code":["c501"]}]}
我的问题是如何在我的情况下使用 ng-repeat 在 html 中打印 json 数据?
提前谢谢...
【问题讨论】:
标签: html angularjs json node.js