我想使用jquery-treegrid在角度2中創建樹表。 1.我在package.json上添加了jquery-treegrid依賴項。 2.安裝打字稿jQuery庫: TSD中安裝jQuery 3.添加HTML代碼:angular2中的表樹
<table class="tree">
<tr class="treegrid-1">
<td>Root node</td><td>Additional info</td>
</tr>
<tr class="treegrid-2 treegrid-parent-1">
<td>Node 1-1</td><td>Additional info</td>
</tr>
<tr class="treegrid-3 treegrid-parent-1">
<td>Node 1-2</td><td>Additional info</td>
</tr>
<tr class="treegrid-4 treegrid-parent-3">
<td>Node 1-2-1</td><td>Additional info</td>
</tr>
</table>
我的組件類:
declare var jQuery:any;
@Component({
selector: '[configuration]',
template: require('./configuration.html'),
encapsulation: ViewEncapsulation.None,
styles: [require('./configuration.scss')],
directives: [Widget, TablesBackgrid, DataTableDirectives],
providers: [ConfigurationService,
HTTP_PROVIDERS],
pipes: [SearchPipe]
})
export class Configuration implements AfterViewInit, OnInit {
data: ISystem[];
errorMessage: string;
constructor(private configurationService: ConfigurationService, private rootNode: ElementRef) {
}
ngAfterViewInit() {
jQuery(this.rootNode.nativeElement.find('.tree')[0]).treegrid();
}
ngOnInit(): void {
this.configurationService.getSystems()
.subscribe(systems => this.data = systems,
error => this.errorMessage = <any>error);
}
}
錯誤控制檯:
TypeError: this.rootNode.nativeElement.find is not a function
我以下在這個論壇上的答案,它沒有奏效。 是否有其他插件在angular2中運行表樹?