我正在尝试将数组打印到表
这是相关代码
JS:
var d = [[
'12:00',
'X-Files',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non nisi in velit tristique scelerisque. Sed quis ipsum a nisl euismod.',
'Mikligarður',
'2'
]];
(我知道那些方括号太多但会有更多条目)
angular.module('angularBowerApp')
.controller('MidCtrl', ['$scope',
function($scope) {
$scope.dagskra= d;
}
]);
HTML:
<table class="table table-responsive table-hover">
<tr ng-repeat="a in dagskra">
<td ng-repeat="b in a"></td>
</tr>
</table>
但是当我运行该程序时,它不会打印任何内容
答案 0 :(得分:1)
没错,你只需要使用你的b
<td ng-repeat="b in a">{{b}}</td>
var d = [[
'12:00',
'X-Files',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non nisi in velit tristique scelerisque. Sed quis ipsum a nisl euismod.',
'Mikligarður',
'2'
]];
angular.module('angularBowerApp',[])
.controller('MidCtrl', ['$scope',
function($scope) {
$scope.dagskra= d;
}
]);
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<table ng-app="angularBowerApp" ng-controller="MidCtrl" class="table table-responsive table-hover">
<tr ng-repeat="a in dagskra">
<td ng-repeat="b in a">{{b}}</td>
</tr>
</table>
&#13;