diff --git a/modules/ng2-dragula/src/components/dragula.directive.ts b/modules/ng2-dragula/src/components/dragula.directive.ts index c65af526..88ad8ccd 100644 --- a/modules/ng2-dragula/src/components/dragula.directive.ts +++ b/modules/ng2-dragula/src/components/dragula.directive.ts @@ -12,15 +12,12 @@ export class DragulaDirective implements OnChanges, OnDestroy { private subs: Subscription; - private container: any; + private get container(): HTMLElement { + return this.el && this.el.nativeElement; + } private group: Group; - private el: ElementRef; - private dragulaService: DragulaService; - public constructor(el: ElementRef, dragulaService: DragulaService) { - this.el = el; - this.dragulaService = dragulaService; - this.container = el.nativeElement; + public constructor(private el: ElementRef, private dragulaService: DragulaService) { } public ngOnChanges(changes: {dragula?: SimpleChange, dragulaModel?: SimpleChange}): void { diff --git a/modules/ng2-dragula/src/components/dragula.service.ts b/modules/ng2-dragula/src/components/dragula.service.ts index 41b060b5..d01a16d4 100644 --- a/modules/ng2-dragula/src/components/dragula.service.ts +++ b/modules/ng2-dragula/src/components/dragula.service.ts @@ -166,7 +166,6 @@ export class DragulaService { let sourceModel = drake.models[drake.containers.indexOf(source)]; sourceModel = sourceModel.slice(0); // clone it const item = sourceModel.splice(dragIndex, 1)[0]; - drake.models[drake.containers.indexOf(source)] = sourceModel; // console.log('REMOVE'); // console.log(sourceModel); this.dispatch$.next({ @@ -196,7 +195,6 @@ export class DragulaService { sourceModel = sourceModel.slice(0) item = sourceModel.splice(dragIndex, 1)[0]; sourceModel.splice(dropIndex, 0, item); - drake.models[drake.containers.indexOf(source)] = sourceModel; // this was true before we cloned and updated sourceModel, // but targetModel still has the old value targetModel = sourceModel; @@ -216,8 +214,6 @@ export class DragulaService { } targetModel = targetModel.slice(0) targetModel.splice(dropIndex, 0, item); - drake.models[drake.containers.indexOf(source)] = sourceModel; - drake.models[drake.containers.indexOf(target)] = targetModel; if (isCopying) { try { target.removeChild(dropElm);