angular - 角度扩展一个类来改变输入
问题描述
所以我正在构建一个组织结构图,扩展一个第三方库:
https://github.com/dabeng/ng-orgchart
我正在尝试更改图表中显示的内容。以下是一些示例数据:
datasource = {
'id': '1',
'name': 'Lao Lao',
'title': 'general manager',
'routing' : 'abc'
'children': [
{ 'id': '2', 'name': 'Bo Miao', 'title': 'department manager', 'routing': 'abd' },
{ 'id': '3', 'name': 'Su Miao', 'title': 'department manager', 'routing': 'bcd'}
]
}
我正在扩展这个类:
并尝试像这样更改其中一个输入:
export class OrgChartComponent extends OrgChartContainer {
@Input() nodeContent = ['title', 'routing'];
但我收到以下错误:
Property 'nodeContent' in type 'OrgChartComponent' is not assignable to the same property in base type 'ChartContainerComponent'.
Type 'string[]' is not assignable to type 'string'.
我怎样才能做到这一点,以便我可以将数据中的多个内容放入 nodeContent 中?我不只是想要标题,我还希望路由号码也显示在那里。
解决方案
nodeContent 属性是字符串,而不是 ChartContainerComponent 中的字符串数组(请参阅您发布的github 链接)。在 OrgChartComponent 中分配单个字符串值
推荐阅读
- mysql - 如何获取上个月的水读数值并从mysqli中的同一张表中减去电流
- python - 通过 Python(特殊字符)将 CSV 推送到 PostgreSQL
- database - ORA-01440 在带有数据的 NULL 精度列上设置精度为 38 时出错?
- eve - 由于后端列更改而覆盖 Python Eve 端点?
- css - IE11:在锚标签上方添加额外的空间
- r - 基于每行不同列中的重复值的子集数据框
- oracle - 如果我在没有调试的情况下编译 Oracle 10g 对象会有什么影响?
- python - 根据另一个类在 django 中动态加载特定应用程序的最佳方法是什么?
- javascript - $ 工作正常,但 $.ajax 不是一个函数(不是苗条的)
- php - 在没有 fosuserbundle 的情况下激活帐户后登录注册用户