When trying to integrate angular-tree-component into a project created with dotnet new angular
, I consistently run into an exception:
void(0) is not a function.
Either the tree never appears, or it appears briefly, but then the error happens and it disappears. I imagine this is due to a package versioning issue, as the component's own demo works fine. But I have no idea which package, or what a work-around might be.
I've cross-posted this as an issue to the angular-tree-component forums and also made various attempts available as a public repo.
Any ideas?
I have just tested it myself and it was working on chrome version 73.0.3683.86. I have used Visual studio code, but you can use anything you want.
dotnew new angular
command - this will create a .net core applicationng new tree-test
command - it creates an angular app names tree-test. Select yes
, when prompted and then choose scss
formatcd tree-test
- to change working folder to a newly created angular appnpm install --save angular-tree-component
- this will install your component to the applicationtree-test>src>styles.scss
file and add a line in there: @import '~angular-tree-component/dist/angular-tree-component.css';
- this will make your tree styles workapp.module.ts
file and add import { TreeModule } from 'angular-tree-component';
to the header and set up import like this: imports: [..., TreeModule.forRoot()]
app.component.html
file and replace everything with <tree-root [nodes]="nodes" [options]="options"></tree-root>
app.component.ts
and replace all AppComponent
class content with the following: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' } ] } ] } ]; options = {};
ng serve
command, wait until it completes and open your browser in http://localhost:4200
. You will see a nice tree there.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With