(function(l) {
    l.module("angularTreeview", []).directive("treeModel", function($compile) {
        return {
            restrict: "A",
            link: function(a, g, c) {
                var arr = [];
                var e = c.treeModel,
                    h = c.nodeLabel || "label",
                    d = c.nodeChildren || "children",
                    k = '<ul><li class="cssmenulist" data-ng-repeat="node in ' + e + '"><div data-ng-class="node.selected" class="cssmenulistdiv" data-ng-click="selectNodeLabel(node, $event)"><i class="collapsed" data-ng-show="node.' + d + '.length && node.collapsed" data-ng-click="selectNodeHead(node, $event)"></i><i class="expanded" data-ng-show="node.' + d + '.length && !node.collapsed" data-ng-click="selectNodeHead(node, $event)"></i><i class="normal" data-ng-hide="node.' +
                    d + '.length"></i> <span>{{node.' + h + '}}</span></div><div data-ng-hide="node.collapsed" data-tree-model="node.' + d + '" data-node-id=' + (c.nodeId || "id") + " data-node-label=" + h + " data-node-children=" + d + "></div></li></ul>";
                e && e.length && (c.angularTreeview ? (a.$watch(e, function(m, b) {
                
                    arr.push(b);
                    g.empty().html($compile(k)(a))
                }, !1), a.selectNodeHead = a.selectNodeHead || function(a, b) {
                    
                    b.stopPropagation && b.stopPropagation();
                    b.preventDefault && b.preventDefault();
                    b.cancelBubble = !0;
                    b.returnValue = !1;
                    a.collapsed = !a.collapsed
                    
                }, a.selectNodeLabel = a.selectNodeLabel || function(c, b) {
                     if(c.issub){
                        b.stopPropagation && b.stopPropagation();
                        b.preventDefault && b.preventDefault();
                        b.cancelBubble = !0;
                        b.returnValue = !1;
                        a.currentNode && a.currentNode.selected && (a.currentNode.selected = void 0);
                        a.currentNode = c
                       // c.selected = "selected";
                        a.treeMenuClick(c);
                    }
                }) : g.html($compile(k)(a)))
            }
        }
    })
})(angular);