我,安装有进口角树组件,并试图将其设置使用下面的步骤提供了基本的例子https://angular2-tree.readme.io/角Tree组件无法正常工作
但不幸的是,我只看到了根节点和没有扩大。如果发生任何错误,发布代码可以让人看到蝙蝠吗?请帮我理解我显然无法看到的错误。
模块:
import { NgModule } from '@angular/core';
import { TreeModule } from 'angular-tree-component';
@NgModule({
imports: [
TreeModule
],
declarations: [],
providers: []
})
export class CourseCreationModule { }
组件:
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
@Component({
selector: 'app-container',
templateUrl: './container.component.html',
styleUrls: ['./container.component.css']
})
export class ContainerComponent implements OnInit {
tree: any;
constructor() { }
getCourseDetails() {
this.createLessonTree();
}
createLessonTree() {
this.tree = [
{
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' }
]
}
]
}
];
}
ngOnInit() {
this.route.params.subscribe(params => {
this.courseId = params['id'];
this.getCourseDetails();
});
}
HTML:
<tree-root [nodes]="tree"></tree-root>
相信没有错误的语法时才我可以看到root1
和root2
。
谢谢。
你在哪里调用'getCourseDetails()'? – ronenmiller