salix/front/core/components/treeview/content.js

40 lines
1013 B
JavaScript
Raw Normal View History

2019-10-02 07:54:52 +00:00
import ngModule from '../../module';
class Controller {
2019-10-08 05:22:38 +00:00
constructor($element, $scope, $compile) {
2019-10-02 07:54:52 +00:00
this.$element = $element;
2019-10-08 05:22:38 +00:00
this.$scope = $scope;
this.$compile = $compile;
2019-10-02 07:54:52 +00:00
}
$onInit() {
2019-10-08 05:22:38 +00:00
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);
2019-10-04 10:20:49 +00:00
this.$element.append($clone);
2019-10-08 05:22:38 +00:00
}
2019-10-02 07:54:52 +00:00
}
2019-10-04 10:20:49 +00:00
$onDestroy() {
if (this.$contentScope)
this.$contentScope.$destroy();
}
2019-10-02 07:54:52 +00:00
}
2019-10-08 05:22:38 +00:00
Controller.$inject = ['$element', '$scope', '$compile'];
2019-10-02 07:54:52 +00:00
ngModule.component('vnTreeviewContent', {
controller: Controller,
bindings: {
2019-10-02 12:12:17 +00:00
item: '<'
},
require: {
treeview: '^vnTreeview'
2019-10-02 07:54:52 +00:00
}
});