Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head>
    <meta charset="utf-8">
    
    <title>Add Rows and columns</title>

    <link href="https://cdn.foundation5.zurb.com/foundation.css" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
  </head>

  <body>
    <div ng-app="productsTableApp">
          <div ng-controller="ProductsController">
            <p>JSON data: <br/>{{data}}
            </p>
            <label>Click on buttons to add or remove columns/rows</label>
            
                <input class="button" type="button" value="+Col" ng-click="addColumn()"/>
                <input class="button" type="button" value="+Row" ng-click="addRow()"/>
 
                <table>
                    <tr ng-repeat="datum in data">
                        <td> <button data-ng-click="removeRow($index)">Remove row</button></td>
                        <td> EN: </td>
                        <td ng-repeat="field in datum">
                          <input type="text" ng-model="field.en"/>
                  			<button ng-click="removeColumn($index)">Remove</button>
                  		 </td>
                    </tr>
                </table>

          </div>
     </div>
   </body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
// Products Table Angular App
angular.module('productsTableApp', [])

// create a controller for the table
.controller('ProductsController', function($scope){
  // initialize the array
  $scope.data=[[{"en":"test"}]
               ,[{"en":"test1"}]
               ,[{"en":"test2"}]
               ,[{"en":"test3"}]
               ,[{"en":"test4"}]];

	// add a column
  $scope.addColumn = function(){
    //you must cycle all the rows and add a column 
    //to each one
    $scope.data.forEach(function($row){
      $row.push({"en":""})
    });
  };

  // remove the selected column
  $scope.removeColumn = function (index) {
    // remove the column specified in index
    // you must cycle all the rows and remove the item
    // row by row
    $scope.data.forEach(function (row) {
      row.splice(index, 1);
		
      //if no columns left in the row push a blank array
      if (row.length === 0) {
        row.data = [];
      }
    });
  };

  // remove the selected row
  $scope.removeRow = function(index){
    // remove the row specified in index
    $scope.data.splice( index, 1);
    // if no rows left in the array create a blank array
    if ($scope.data.length() === 0){
      $scope.data = [];
    }
  };

  //add a row in the array
  $scope.addRow = function(){
    // create a blank array
    var newrow = [];
		 
      // if array is blank add a standard item
      if ($scope.data.length === 0) {
        newrow = [{'en':''}];
      } else {
        // else cycle thru the first row's columns
        // and add the same number of items
        $scope.data[0].forEach(function (row) {
          newrow.push({'en':''});
        });
      }
    // add the new row at the end of the array 
    $scope.data.push(newrow);
  };
});

              
            
!
999px

Console