import ngModule from '../../module'; class Controller { constructor($element, $scope, $compile) { this.$element = $element; this.$scope = $scope; this.$compile = $compile; } $onInit() { if (this.item.parent) { this.treeview.$transclude(($clone, $scope) => { this.$contentScope = $scope; $scope.item = this.item; this.$element.append($clone); }); } else { let template = `{{$ctrl.treeview.rootLabel}}`; let $clone = this.$compile(template)(this.$scope); this.$element.append($clone); } } $onDestroy() { if (this.$contentScope) this.$contentScope.$destroy(); } } Controller.$inject = ['$element', '$scope', '$compile']; ngModule.component('vnTreeviewContent', { controller: Controller, bindings: { item: '<' }, require: { treeview: '^vnTreeview' } });