【发布时间】:2017-02-26 00:15:29
【问题描述】:
我有这个文件。
wordCloud.ts
export class HomePageComponent {
wordcloudData : Array<string>;
private searchField : string;
private wordsApi : string;
wordClouds: any[] = [];
errorMessage: string;
listId:any = 1;
@Input() data : any;
@Input() testProperty : any;
@Input() dataField : string;
@Input() apiUrl : string;
constructor(public wordCloudListService: LexiconListService) {}
getWordCloudList() {
this.wordCloudListService.get('/assets/adhoc-search.json')
.subscribe(
wordClouds => {
EmitterService.get(this.listId).emit(wordClouds);
},
error => this.errorMessage = <any>error
);
}
ngOnInit() {
this.getWordCloudList();
EmitterService.get(this.listId).subscribe((wordClouds:any) => {this.wordClouds});
}
}
wordCloud.html
<div class="center" style="margin: 0 auto; width: 30%; padding-top: 100px;">
<cst-word-cloud [data]="{{wordClouds}}"></cst-word-cloud>
</div>
如您所见,我正在尝试加载 json 数据并将数据显示到 wordCloud hmtl 中。我目前在执行此操作时遇到困难?有什么我做错了吗?如何传递 wordClouds 数组中的值来显示它?
【问题讨论】:
标签: html json angular typescript