需要用ngfor解决
need solution with ngfor
//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>
此代码无效,输出为空白。如果您有 this.pls 的解决方案,请告诉我
你在 *ngfor
中犯了一个小语法错误
它遵循驼峰式大小写,其中 f 必须大写。
正确的代码附在下面:
<ul>
<li *ngFor="let hero of heroes">
{{hero.name}}
</li>
</ul>
//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>
此代码无效,输出为空白。如果您有 this.pls 的解决方案,请告诉我
你在 *ngfor
中犯了一个小语法错误
它遵循驼峰式大小写,其中 f 必须大写。
正确的代码附在下面:
<ul>
<li *ngFor="let hero of heroes">
{{hero.name}}
</li>
</ul>