Indeterminate tree structure component is created using Angular 4 and it is useful to have tristate checkboxes

To preview demo of Indeterminate TreeStructure component, Click here
Download the Indeterminate TreeStructureComponent folder and install the required packages and run the application.
Installing node_module use command npm install
Run ng serve for a dev server. Navigate to http://localhost:4200/.
The app will automatically reload if you change any of the source files.
Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.
- Provide the JSON data for creating the Tree Structure.
TreeStructure Json Interface Format:
interface TreeNode {
label: string;
checked: boolean;
children: TreeNode[];
}
-
If you check the all child input checkboxes, then the parent checkbox is checked and viceversa
-
If you uncheck the all child input checkboxes, then the parent checkbox is unchecked and viceversa.
-
If you uncheck any one of the child checkbox, then the parent of the child checkbox will goes to the indeterminate state.
<app-tree-node [node]="tree" (selectEvents)="handleSelection( $event )" [selectedNode]="selectedTreeNode"></app-tree-node>
-
[node]: It allows you to keep your Json Data in Treestructure Formate.
-
[selectedNode]: It allows you to highlight the node which you have selected.
- handleSelection( $event) is a function which will emit the current selectedNode.
handleSelection( node: TreeNode ): void {
console.group( 'Selected Tree Node' );
console.log( 'Label:', node.label );
}