需要解决方案与ngfor

时间:2017-05-04 05:39:12

标签: angular angular2-template angular2-forms

//appcomponent.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  heroes=[{name:"superman"},{name:"heman"}];
}
//app.component.html

<ul><li *ngfor="let hero of heroes">{{hero.name}}</li></ul>

此代码不起作用,并为我提供空白输出。如果你有这方面的解决方案,请告诉我

1 个答案:

答案 0 :(得分:-1)

*ngfor你犯了一个小的语法错误 它遵循骆驼套管,其中f必须是大写的。

下方附有正确的代码:

<ul>
  <li *ngFor="let hero of heroes">
    {{hero.name}}
  </li>
</ul>
相关问题