【发布时间】:2018-06-01 08:02:36
【问题描述】:
我已经使用这两个单独的文件将外部 json 文件中的数据提取到一个数组中。 服务文件
getProjectNames(){
return this._http.get(this._url)
.map((response:Response) => response.json())
}
组件文件
ngOnInit(){
this.roadmapGeneratorService.getProjectNames()
.subscribe(resProjectNames => this.projectNames = resProjectNames)
}
现在我必须将projectNames 的值显示为p-dropdown element of primeng。为此,我需要将 projectNames 数组转换/复制为带有标签和值字段的数组。
for(let index=0;index<this.len;index++)
{
this.portNames.push ({label: this.projectNames[index], value: ''});
}
但它没有帮助。
【问题讨论】:
标签: angular angular2-services primeng angular2-components