【发布时间】:2017-11-07 11:00:20
【问题描述】:
在我拥有的组件内部
export class AppComponent implements OnInit {
public errorMsg :number =10 ;
public doughnutChartOptions: any = {
cutoutPercentage: 85,
elements: {
center: {
text: this.errorMsg + ' Energy produced in the Energy',
fontColor: '#fff',
fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
fontSize: 24,
fontStyle: 'normal'
}
}
};
}
text: this.errorMsg + ' some thing',
这是一个属性接受的字符串,所以在这里我必须将数字传递给字符串,如何在 angular4、typescript 2.5 中做到这一点
【问题讨论】:
-
你是说你的所作所为给了你一个错误吗?如果是这样,错误是什么?
-
TypeScript 具有与 JS 相同的类型强制转换,因此在字符串上下文中使用时,数字会自动转换为字符串。
-
我已经关闭了这个话题,从 Gunter 和 Saurabh 那里得到了一个清晰的想法,感谢宝贵的 cmets
标签: angular typescript angular2-template