looker/angular-tree-control

Name: angular-tree-control

Owner: looker

Description: Angular JS Tree

Forked from: wix/angular-tree-control

Created: 2015-05-04 23:42:42.0

Updated: 2017-02-28 00:53:12.0

Pushed: 2017-02-28 00:53:10.0

Homepage: http://wix.github.io/angular-tree-control

Size: 1492

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Angular Tree Control

Bower version Build Status Coverage Status

Pure AngularJS based tree control component.

ScreenShot

To get started, check out wix.github.io/angular-tree-control

Why yet another tree control

We have tried a number of tree controls built for angular and experience a of issues with each. As a result we decided to build a new tree control with the following design guidelines

Installation

Bower: bower install angular-tree-control

The tree control can be used as a Dom element or as an attribute.

Copy the script and css into your project and add a script and link tag to your page.

ipt type="text/javascript" src="/angular-tree-control.js"></script>
 link for CSS when using the tree as a Dom element -->
k rel="stylesheet" type="text/css" href="css/tree-control.css">
 link for CSS when using the tree as an attribute -->
k rel="stylesheet" type="text/css" href="css/tree-control-attribute.css">

Add a dependency to your application module.

lar.module('myApp', ['treeControl']);

Add tree elements to your Angular template

 as a Dom element -->
econtrol class="tree-classic"
ree-model="dataForTheTree"
ptions="treeOptions"
n-selection="showSelected(node)"
elected-node="node1">
mployee: {{node.name}} age {{node.age}}
eecontrol>
 as an attribute -->
 treecontrol class="tree-classic"
ree-model="dataForTheTree"
ptions="treeOptions"
n-selection="showSelected(node)"
elected-node="node1">
mployee: {{node.name}} age {{node.age}}
v>

and add the data for the tree

pe.treeOptions = {
nodeChildren: "children",
dirSelectable: true,
injectClasses: {
    ul: "a1",
    li: "a2",
    liSelected: "a7",
    iExpanded: "a3",
    iCollapsed: "a4",
    iLeaf: "a5",
    label: "a6",
    labelSelected: "a8"
}

pe.dataForTheTree =

{ "name" : "Joe", "age" : "21", "children" : [
    { "name" : "Smith", "age" : "42", "children" : [] },
    { "name" : "Gary", "age" : "21", "children" : [
        { "name" : "Jenifer", "age" : "23", "children" : [
            { "name" : "Dani", "age" : "32", "children" : [] },
            { "name" : "Max", "age" : "34", "children" : [] }
        ]}
    ]}
]},
{ "name" : "Albert", "age" : "33", "children" : [] },
{ "name" : "Ron", "age" : "29", "children" : [] }

Usage

Attributes of angular treecontrol

The tree labels

The Angular Tree control uses a similar paradigm to ng-repeat in that it allows using the current node as well as values from the parent scope. The current node is injected into the scope used to render the label as the `node` member (unlike ng-repeat, we do not allow to name the current node item in the transcluded scope).

In order to render a template that takes a value `Xfrom the parent scope of the tree and value ``Y``` from the current node, use the following template

tyling

angular-tree-control renders to the following DOM structure

following CSS classes are used in the built-in styles for the tree-control.
tional classes can be added using the options.injectClasses member (see above)

ee-expanded, tree-collapsed, tree-leaf - are placed on the 'ul' element
ee-branch-head, tree-leaf-head - are placed on the 'i' elements. We use those classes to place the icons for the tree
ee-selected - placed on the div around the label


eference

 tree control is based in part on the angular.treeview component
gular.treeview: http://ngmodules.org/modules/angular.treeview

icense

MIT License.

[LICENSE](https://github.com/wix/angular-tree-control/blob/master/LICENSE)

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.