我的问题类似于线程
JSON看起来像这样
{ " id":" String", "马克" : { " NumMin的":"整数" " NumMax的值":"整数" " subjectname":" string", } }
只是会有一个额外的功能,用户将不输入需要生成的行,然后将根据将从数据库中提取的动态JSON文件生成表。提前致谢
答案 0 :(得分:0)
请告诉我这是否对您有帮助!
let app = angular.module('app', []);
app.controller('ctrl', ['$scope', ($scope) => {
$scope.numberOfRows = 0;
$scope.data = [];
$scope.$watch('data', () => {
console.log($scope.data);
}, true);
}]);
app.filter('range', function () {
return function (input, total) {
total = parseInt(total, 10);
for (let i = 0; i < total; i++) {
input.push(i);
}
return input;
};
});
<div ng-app="app">
<div ng-controller="ctrl">
<input type="number" ng-model="numberOfRows" />
<br />
<table width="100%">
<tr>
<th>nummin</th><th>nummax</th><th>...</th>
</tr>
<tr ng-repeat="i in [] | range:numberOfRows">
<td>
<input type="number" ng-model="data[i].nummin" />
</td>
<td>
<input type="number" ng-model="data[i].nummax" />
</td>
<td>...</td>
</tr>
</table>
</div>
</div>