*ngFor Objekt-Attribut undefiniert

Ich bin ab Gewinkelt 2 aus Winkel-1, und ich kann nicht herausfinden, wie zu verwenden ngFor auf ein Objekt-Attribut.
this.myVar definiert ist, auf das Ergebnis einer HTTP-Anforderung definiert, die den attr Attribut.

Hier ist mein code:

# my_page.ts
import {Page} from 'ionic-angular';
import {MyService} from '../../services/my_service';

@Page({
  templateUrl: 'build/pages/my_page/my_page.html',
  providers: [MyService]
})


export class MyPage {
  public myVar;

  constructor(private myService: MyService) {
    this.myService.fetch().subscribe(
      data => this.myVar = data
    );
  }
}

# my_page.html
<div *ngFor="#item of myVar.attr">
</div>

- Und dies ist der Fehler:

EXCEPTION: TypeError: Cannot read property 'attr' undefined in [myVar.attr in ...]

Danke!

InformationsquelleAutor akz92 | 2016-04-12
Schreibe einen Kommentar