【发布时间】:2017-09-26 11:57:00
【问题描述】:
我有以下示例 sn-p。我想通过ng-repeat 在角度表中显示我下面的json 对象,这是我从angular controller 脚本生成的。我已经完成了以下操作,但我不确定为什么表格没有生成并且它的数据没有显示。请让我知道,我不确定这里有什么问题。 Fiddle 可用。
需要得到类似的输出:
Text IND US UK AUS
No 100 200 170 50
html:
<div ng-controller="TestCtrl">
</div>
app.js:
var testmodule = angular.module('myModule', []);
testmodule.controller('TestCtrl', function ($scope) {
$scope.mydata = [{
"a": ["IND", "US", "UK", "AUS"],
"b": ["100", "200", "170", "50"],
"c": "Text",
"d": "No",
}];
var mytable= angular.element(' <div class="table-responsive"> <table class="table" ng-repeat="item in mydata track by $index"> <thead> <tr> <td>{{item.c}}</td><td ng-repeat="c1 in item.a track by $index">{{c1}}</td></tr></thead> <tbody> <tr> <td>{{p.d}}</td><td ng-repeat="d1 in p.b track by $index">{{d1}}</td></tr></tbody> </table> </div>');
console.log("mytable: "+JSON.stringify(mytable));
});
【问题讨论】:
-
您希望 console.log 是什么样的?
标签: javascript angularjs json angularjs-ng-repeat