title: Cannot read property 'name' of undefined angular 4
body: <p>I am trying to print a value in the template of component.</p>
  
  <p>But I am getting the above error
  <code>Cannot read property 'name' of undefined</code></p>
  
  <p>I have removed the extra contents from code for this question. I want to access the first row of the details.</p>
  
  <p>Components file</p>
  
  <pre><code>import {
    Component
  } from '@angular/core';
  import {
    Person
  } from './person';
  import {
    getPersonDetailsService
  } from './person.service';
  
  @Component({
    selector: 'my-app',
    template: `
        {{data[0].name}}
        `
  })
  export class AppComponent {
    data: Person[] = [];
    ngOnInit(): void {
      this.getPersonDetailsService.getData()
        .then(data =&gt; this.data = data.slice(1, 5));
    }
  
  }
  </code></pre>