I am working on Angular JS task where i need to take input from a text box and form rows which has two input fields.Consider that rows and columns Upon entering values in that formed two input fields. A Table with rows and columns should form. Here is a fiddle link
https://jsfiddle.net/iamsaisanthosh/r1zync3g/
var app = angular.module('app', []);
app.controller('ctrl', function($scope) {
$scope.table = [];
$scope.cols = [];
$scope.rows = [];
$scope.arr = [];
$scope.arh = [];
$scope.trr = [];
$scope.makeArray = function() {
$scope.trr.length = 0;
for (var k = 0; k < parseInt($scope.table); k++) {
$scope.trr.push(k);
}
$scope.arr.length = 0;
for (var i = 0; i < parseInt($scope.rows); i++) {
$scope.arr.push(i);
}
$scope.arh.length = 0;
for (var j = 0; j < parseInt($scope.cols); j++) {
$scope.arh.push(j);
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<div ng-app="app">
<div ng-controller="ctrl">
<input ng-model="table" type="text" ng-change="makeArray()" />
<table>
<tr ng-repeat="o in trr">
<td> <input ng-model="rows[$index]" type="text" ng-change="makeArray()" />
</td>
<td> <input ng-model="cols[$index]" type="text" ng-change="makeArray()" /></td>
</tr>
</table>
<div>
<table>
<tr ng-repeat="o in arr">
<td ng-repeat="o in arh">Col</td>
</tr>
</table>
</div>
</div>
</div>
I can take input from a text box and form rows. Upon entering values in the formed input fields a table with values entered is forming. Table forms only for the first row inputted values The problem is i can't do that for more than one row
Not able form Table for second row inputted values In the above fiddle Enter 2 in the text field 2 rows will form with two input fields Enter 3 and 4 respectively in the first row input fields You can see a table forming with 3 rows and 4 columns I need the same to happen when i enter values in the second row A second table should form