【发布时间】:2016-12-19 09:15:34
【问题描述】:
我一直在尝试使用https://github.com/d-koppenhagen/angular-tag-cloud-module的标签云模块,我的数据对象是这样的:
{ "Speech": 4, "E-commerce": 1, "Meeting": 1, "Garena": 1 , "Silicon valley": 1}
根据模块的指南,数据数组应该像下面这样插入:
[ {text: "Speech", weight: 4}, {text: "E-commerce", weight: 1}, {text: "Meeting", weight: 1},{text: "Garena", weight: 1}, {text: "Sillicon valley", weight: 1}]
我的代码在下面,最近用Typescript编码,希望有人能给我提示!
var post_tags: Array<string> = post['tags'];
post_tags.forEach(element => {
this.counts[element] = ( this.counts[element] || 0)+1;
this.tags.push({
text: Object.keys(this.counts),
weight: this.counts[element]
});
});
【问题讨论】:
标签: javascript angular typescript tag-cloud