This repository has been archived on 2020-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
angularjs-batarang/js/directives/mtree.js
2012-07-02 14:09:51 -07:00

35 lines
1.1 KiB
JavaScript

// model tree
panelApp.directive('mtree', function($compile) {
return {
restrict: 'E',
terminal: true,
scope: {
val: '=val',
edit: '=edit',
inspect: '=inspect'
},
link: function (scope, element, attrs) {
// this is more complicated then it should be
// see: https://github.com/angular/angular.js/issues/898
element.append(
'<div class="scope-branch">' +
'<a href ng-click="inspect()">Scope ({{val.id}})</a> | ' +
'<a href ng-click="showState = !showState">toggle</a>' +
'<div ng-class="{hidden: showState}">' +
'<ul>' +
'<li ng-repeat="(key, item) in val.locals">' +
'{{key}}' +
'<input ng-class="{hidden: !item}" ng-model="item" ng-change="edit()()">' +
'</li>' +
'</ul>' +
'<div ng-repeat="child in val.children">' +
'<mtree val="child" inspect="inspect" edit="edit"></mtree>' +
'</div>' +
'</div>' +
'</div>');
$compile(element.contents())(scope.$new());
}
};
});