title: dynamically adding a new Table object in Angular 4
body: <p><strong>I will try create a new Table object using an object,but the problem am facing is while add a new row(new table object) it shows a number of columns of previous object, I need new table object with single row, if i need column to particular row it should add column to that row only</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>.TS
  
  import { Component } from '@angular/core';
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent {
   
  r1=1;
  
  oldJson = [
    {
      key1: this.r1
    }
  ]
  
  newJson= [
    {
      key2: this.oldJson
    }
  ]
  
  
   new1(){
    try{ 
          this.r1 = this.r1 + 1;
          this.oldJson.push({
            key1: this.r1
          });
        } catch(error){ console.log(error)}
        }
  
  
        new2() {
          this.newJson.push({
        key2: this.oldJson
          });
        }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.css
  
  table {
      font-family: arial, sans-serif;
      border-collapse: collapse;
      width: 100%;
  }
  
  td, th {
      border: 1px solid #dddddd;
      text-align: left;
      padding: 8px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>.html
  
  &lt;table *ngFor="let item of newJson"  &gt;
        &lt;tr&gt;                   
             &lt;td *ngFor="let x of item.key2" &gt;
          &lt;/td&gt;
          &lt;button class="add" (click)="new1(i)"&gt;addcolumn&lt;/button&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;br&gt;
    &lt;br&gt;
  &lt;button class="add" (click)="new2(i)"&gt;addrow&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>In this snippet typescript functions not working but it works in vs code, so please consider only the code.
  thanks in advance</p>