我,安裝有進口角樹組件,並試圖將其設置使用下面的步驟提供了基本的例子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