javascript - dynamic table row generation using ng-repeat -
my problem similar thread
json looks this
{ "id": "string", "marks" : { "nummin":"integer" "nummax":"integer" "subjectname": "string", } }
just there additional feature user going enter no of rows need generated , table generated according dynamic json file fetched database. in advance
try out this js-fiddle.
let me know if helped you!
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); (let = 0; < 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>
wiki
Comments
Post a Comment