title: How to extract sub object from rest api response in angular
body: <p>This is <code>employee.component.ts</code>:</p>
  <pre><code>export class EmployeeDetailsComponent implements OnInit 
  {
      empResponseList: EmpResponse[];
  
      showEmps() {
          this.paymentService.getAllEmps().subscribe((data: EmpResponse[]) =&gt; {
                 this.empResponseList = data;
  
                                                                                              
     });
  }
  </code></pre>
  <p>This is we are getting as response  data = [employee:{},department[] ] --&gt;from this we need to extra department[] in component it self.</p>
  <p>This is <code>EmployeeService.ts</code>:</p>
  <pre><code>getAllEmps(): Observable&lt;EmpResponse[]&gt; 
  {
      return this.http.get&lt;EmpResponse[]&gt;(this.baseUrl + `/api/emps`);
  }
  </code></pre>
  <p>This is <code>EmployeeResponse</code> model in Angular:</p>
  <pre><code> export class EmpResponse {
        department: Department;
        employee: Employee[];
      }
  </code></pre>
  <p>When I call the <code>showEmps()</code> method it will return</p>