javascript - dynamic table row generation using ng-repeat -




my problem similar thread

dynamic table creation ng-repeat in angularjs

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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -