title: Why data is not fetched from the observable?
body: <p>I've a service which makes a GET request to the server for fetching values.
  Problem is occurring when I'm going to store the value in a variable in component.</p>
  
  <p><strong>abc.service.ts</strong></p>
  
  <pre><code>public data: Category[] = [];
  getPosts():Observable&lt;Category[]&gt; {
      return this.http.get&lt;Category[]&gt;(this.url + '/getAllExamCategory');
  }
  </code></pre>
  
  <p><strong>def.component.ts</strong></p>
  
  <pre><code>ELEMENT_DATA: Category[];
  dataSource: any;
  columnsToDisplay = ['id', 'examCategoryName', 'isActive', 'Action'];
  
  constructor(private adminCategory: AdminCategoryService) { }
  
  ngOnInit() {
      this.adminCategory.getPosts().subscribe((reponse: Category[]) =&gt; {
        if(!reponse) {
          return;
        }
        this.ELEMENT_DATA = reponse;
        this.dataSource = new MatTableDataSource&lt;Category&gt;(this.ELEMENT_DATA);
        this.dataSource.paginator = this.paginator;
      }, error =&gt; {
        console.log(error);
      });
    }
  </code></pre>
  
  <p>I'm not able to understand where am making the mistake. When I'm console logginf the <code>ELEMENT_DATA</code> variable to check it's length it's showing <code>undefined</code>.</p>