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" >
|
||||
<div
|
||||
ng-class="{expanded: item.active}"
|
||||
ng-click="$ctrl.toggle($event, item)"
|
||||
ng-click="$ctrl.onClick($event, item)"
|
||||
class="node clickable">
|
||||
<vn-icon
|
||||
class="arrow"
|
||||
|
|
|
@ -2,41 +2,17 @@ import ngModule from '../../module';
|
|||
import Component from '../../lib/component';
|
||||
|
||||
class Controller extends Component {
|
||||
constructor($element, $scope, $transclude) {
|
||||
super($element, $scope);
|
||||
this.$transclude = $transclude;
|
||||
}
|
||||
|
||||
toggle(event, item) {
|
||||
onClick(event, item) {
|
||||
if (event.defaultPrevented || !item.sons) return;
|
||||
event.preventDefault();
|
||||
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) {
|
||||
this.treeview.onDrop(item, dragged, dropped);
|
||||
}
|
||||
|
||||
get isInsertable() {
|
||||
return Array.isArray(this.parent) || this.parent.childs;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', '$transclude'];
|
||||
|
||||
ngModule.component('vnTreeviewChilds', {
|
||||
template: require('./childs.html'),
|
||||
controller: Controller,
|
||||
|
|
|
@ -6,11 +6,17 @@ class Controller {
|
|||
}
|
||||
|
||||
$onInit() {
|
||||
this.treeview.$transclude((tClone, $scope) => {
|
||||
this.treeview.$transclude(($clone, $scope) => {
|
||||
this.$contentScope = $scope;
|
||||
$scope.item = this.item;
|
||||
this.$element.append(tClone);
|
||||
this.$element.append($clone);
|
||||
});
|
||||
}
|
||||
|
||||
$onDestroy() {
|
||||
if (this.$contentScope)
|
||||
this.$contentScope.$destroy();
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element'];
|
||||
|
||||
|
|
Loading…
Reference in New Issue