title: How to initialize Typescript array interface with observable in Angular
body: <p>I am new to Angular. I have an issue in dependency injection when displaying a list of contacts.
  I have a typescript interface array in which i am passing a static array of contacts which am trying to display in html.</p>
  
  <p>my service class</p>
  
  <pre><code> export class ContactService {
  
        contacts = {
          'contactsList': [
              {'id': 1, 'name': 'Rajesh', 'city': 'bangalore'},
              {'id': 2, 'name': 'Aarjith', 'city': 'london'},
              {'id': 3, 'name': 'Anjan', 'city': 'california'},
              {'id': 4, 'name': 'David', 'city': 'delhi'}
          ]
        };
        constructor(
        ) { }
  
        getContacts(): Observable&lt;Contacts&gt; {
          // send contacts to subscriber
          //return of({} as Contacts);
           return of(this.contacts);
        }
      }
  </code></pre>
  
  <p>model class</p>
  
  <pre><code> export interface Contacts {
        contactsList: Contact[];
   }
  
   export interface Contact {
        id: number;
        name: string;
        city: string;
   }
  </code></pre>
  
  <p>My ContactListComponent </p>
  
  <pre><code>export class ContactListComponent implements OnInit {
  
        contacts:Contacts[]=[];//i am getting error in this line
        constructor(
          private contactService: ContactService
        ) { }
  
        ngOnInit() {
          // get contacts from service and assign it to contacts
          this.contactService.getContacts().subscribe((data) =&gt; {
              this.contacts = data;//error at this line
            });
        }
  </code></pre>
  
  <p>html for displaying</p>
  
  <pre><code>    &lt;p class="title"&gt; Contact Applications &lt;/p&gt;
      &lt;div class="list"&gt;
        &lt;p *ngFor="let contact of contacts"&gt;
          {{contact.name}}
        &lt;/p&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>i am getting the error at the initialization Type 'Contacts' is missing the following properties from type 'any[]': length, pop, push, concat, and 26 more. where i am missing . i have changed the initialization to Contacts=[] but not seems to be working.</p>