40 lines
1013 B
JavaScript
40 lines
1013 B
JavaScript
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 = `<span translate>{{$ctrl.treeview.rootLabel}}</span>`;
|
|
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'
|
|
}
|
|
});
|