Destroy transclude scopes
gitea/salix/1625-worker_department_treeview This commit looks good
Details
gitea/salix/1625-worker_department_treeview This commit looks good
Details
This commit is contained in:
parent
8e80f53d30
commit
366d1123d4
|
@ -3,7 +3,7 @@
|
||||||
<li ng-repeat="item in $ctrl.items" >
|
<li ng-repeat="item in $ctrl.items" >
|
||||||
<div
|
<div
|
||||||
ng-class="{expanded: item.active}"
|
ng-class="{expanded: item.active}"
|
||||||
ng-click="$ctrl.toggle($event, item)"
|
ng-click="$ctrl.onClick($event, item)"
|
||||||
class="node clickable">
|
class="node clickable">
|
||||||
<vn-icon
|
<vn-icon
|
||||||
class="arrow"
|
class="arrow"
|
||||||
|
|
|
@ -2,41 +2,17 @@ import ngModule from '../../module';
|
||||||
import Component from '../../lib/component';
|
import Component from '../../lib/component';
|
||||||
|
|
||||||
class Controller extends Component {
|
class Controller extends Component {
|
||||||
constructor($element, $scope, $transclude) {
|
onClick(event, item) {
|
||||||
super($element, $scope);
|
|
||||||
this.$transclude = $transclude;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle(event, item) {
|
|
||||||
if (event.defaultPrevented || !item.sons) return;
|
if (event.defaultPrevented || !item.sons) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.treeview.onToggle(item);
|
this.treeview.onToggle(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
select(item, value) {
|
|
||||||
this.treeview.onSelection(item, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
onIconClick(icon, item, parent, index) {
|
|
||||||
let parentController = this.parentScope.$ctrl;
|
|
||||||
icon.callback.call(parentController, item, parent, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
onCreate(parent) {
|
|
||||||
this.treeview.onCreate(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDrop(item, dragged, dropped) {
|
onDrop(item, dragged, dropped) {
|
||||||
this.treeview.onDrop(item, dragged, dropped);
|
this.treeview.onDrop(item, dragged, dropped);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isInsertable() {
|
|
||||||
return Array.isArray(this.parent) || this.parent.childs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', '$transclude'];
|
|
||||||
|
|
||||||
ngModule.component('vnTreeviewChilds', {
|
ngModule.component('vnTreeviewChilds', {
|
||||||
template: require('./childs.html'),
|
template: require('./childs.html'),
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
|
|
|
@ -6,11 +6,17 @@ class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onInit() {
|
||||||
this.treeview.$transclude((tClone, $scope) => {
|
this.treeview.$transclude(($clone, $scope) => {
|
||||||
|
this.$contentScope = $scope;
|
||||||
$scope.item = this.item;
|
$scope.item = this.item;
|
||||||
this.$element.append(tClone);
|
this.$element.append($clone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$onDestroy() {
|
||||||
|
if (this.$contentScope)
|
||||||
|
this.$contentScope.$destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Controller.$inject = ['$element'];
|
Controller.$inject = ['$element'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue