Angular 角度树组件的子节点不显示
我尝试从提供的基本示例中实现angular tree组件=> 问题是,在实现之后,我只能看到根节点,而没有expandchild根节点,也看不到。在控制台中没有这样的错误 组成部分:Angular 角度树组件的子节点不显示,angular,typescript,angular5,Angular,Typescript,Angular5,我尝试从提供的基本示例中实现angular tree组件=> 问题是,在实现之后,我只能看到根节点,而没有expandchild根节点,也看不到。在控制台中没有这样的错误 组成部分: @Component({ selector: 'app-category', templateUrl: './category.component.html', styleUrls: [ './category.component.css' ] }) export class Catego
@Component({
selector: 'app-category',
templateUrl: './category.component.html',
styleUrls: [
'./category.component.css'
]
})
export class CategoryComponent implements OnInit {
nodes: any;
options = {};
showpanel: boolean;
categories: CategoriesModel[];
constructor(private adminService: AdminService) {
}
ngOnInit() {
this.showpanel = false;
this.categories = [];
this.adminService.getCategoryData()
.subscribe(
(catData: CategoriesModel[]) => {
this.categories = catData;
this.showpanel = true;
});
this.nodes = [
{
id: 1,
name: 'root1',
children: [
{ id: 2, name: 'child1' },
{ id: 3, name: 'child2' }
]
},
{
id: 4,
name: 'root2',
children: [
{ id: 5, name: 'child2.1' },
{
id: 6,
name: 'child2.2',
children: [
{ id: 7, name: 'subsub' }
]
}
]
}
];
}
}
HTML:
在浏览器中显示:
如果尝试将节点字段定义为:
nodes: any = []
工作正常吗?刚刚在styles.css中导入了angular-tree-component.css,问题得到了解决
@import '../node_modules/angular-tree-component/dist/angular-tree-component.css';
不幸的是,它不起作用。我是否在实现中遗漏了一些东西?它对我不起作用,它本身的源css没有找到
nodes: any = []
@import '../node_modules/angular-tree-component/dist/angular-tree-component.css';