Angular 2 First Item in Array Missing using *ngFor

后端 未结 2 1868
醉酒成梦
醉酒成梦 2021-01-21 06:06

Using the angular quickstart app (https://github.com/angular/quickstart/blob/master/README.md). Using angular 2.1.1

Using *ngFor, the first item of the list doesn\'t app

2条回答
  •  灰色年华
    2021-01-21 06:19

    I don't see any issue, I tried this in this Plunker! and it works.

    import { Component,Input } from '@angular/core';
    
    @Component({
      selector: 'my-app',
      template: `

    Angular 2 First Item in Array Missing using *ngFor

    {{teachers | json}}
    ` }) export class AppComponent { public teachers: string[] = [ "Erty", "Dave", "Sarah", "Walter" ]; } @Component({ selector: 'teacher', template: `

    Teacher {{index}}: {{teacherName}}

    ` }) export class TeacherComponent { @Input() teacherName: string; @Input() index: number; ngOnInit() { console.log(this.teacherName); } }

提交回复
热议问题