title: Angular display categories and subCategories in ul or table
body: <p>I need to display my <strong>categories</strong> in <em><strong>ul</strong></em> or <em><strong>table</strong></em> and on <em><strong>click</strong></em> on the <strong>category</strong> I need to show <em><strong>subcategories</strong></em>, but I don't have idea how I can do that. ;(</p>
  <pre><code>&lt;ul&gt;
    &lt;li&gt;category name&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  <p>I need to do that from an object.</p>
  <pre><code>  cats = [
      {
        &quot;id&quot;: &quot;1&quot;,
        &quot;parent_id&quot;: 'root',
        &quot;category&quot;: &quot;Dress&quot;
      },
      {
        &quot;id&quot;: &quot;17&quot;,
        &quot;parent_id&quot;: &quot;1&quot;,
        &quot;category&quot;: &quot;Dress 2&quot;
      },
  
  
      {
        &quot;id&quot;: &quot;19&quot;,
        &quot;parent_id&quot;: &quot;1&quot;,
        &quot;category&quot;: &quot;Men&quot;
      },
      {
        &quot;id&quot;: &quot;30&quot;,
        &quot;parent_id&quot;: &quot;19&quot;,
        &quot;category&quot;: &quot;Shorts 2&quot;
      },
      {
        &quot;id&quot;: &quot;31&quot;,
        &quot;parent_id&quot;: &quot;19&quot;,
        &quot;category&quot;: &quot;Shorts&quot;
      }
    ]
  </code></pre>
  <p>So I need to change ul or table structure every time when user click on category or subcategory name.</p>
  <p>The Root category is a first display category.</p>
  <p>if it helps i use ngx-datatables on my the project. But I can use default tables. I just need to understand the logic</p>
  <p>Thank You!</p>