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.
- Create a folder and open it with VS Code
- Open a terminal and execute
dotnew new angular
command - this will create a .net core application
- Execute
ng new tree-test
command - it creates an angular app names tree-test. Select yes
, when prompted and then choose scss
format
- Execute
cd tree-test
- to change working folder to a newly created angular app
- Execute
npm install --save angular-tree-component
- this will install your component to the application
- Open
tree-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 work
- Open
app.module.ts
file and add import { TreeModule } from 'angular-tree-component';
to the header and set up import like this: imports: [..., TreeModule.forRoot()]
- Open
app.component.html
file and replace everything with <tree-root [nodes]="nodes" [options]="options"></tree-root>
- Open
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 = {};
- run
ng serve
command, wait until it completes and open your browser in http://localhost:4200
. You will see a nice tree there.