【发布时间】:2017-12-09 18:51:51
【问题描述】:
export class AppComponent {
pickBtnClicked = false;
selectedPickNumber: 'string';
selectedRegion: 'string';
currentPickSelection: any[];
channelList: any[];
constructor(private pickGroupService: PickGroupService, private channelsService: ChannelsService) {}
onPkClick(btnPicked) {
this.pickBtnClicked = true;
this.selectedPickNumber = btnPicked;
}
onRegionClick(regionPicked) {
this.selectedRegion = regionPicked;
this.currentPickSelection = this.pickGroupService.getPickSet(this.selectedPickNumber, this.selectedRegion);
console.log(this.currentPickSelection);
}
}
但下面的 ngFor 并没有从“currentPickSelection”数组中获取任何数据。
<ul class="w3-ul w3-card-4" align="right" >
<li class="list-group-item" *ngFor="let channels of currentPickSelection">
<strong><font size="2">{{ channels.channel }}</font><span class="w3-right"><font size="2">{{ channels.pickCode }}</font></span></strong>
</li>
</ul>
请指教!谢谢
【问题讨论】:
-
你能在这个问题中分享示例 json 响应吗?
console.log(JSON.stringify(this.currentPickSelection));将打印共享数据日志