4

I am using ng2-dragula and with data binding in 2 tables. When a td is drag and drop to another table, it throws the Uncaught TypeError: Cannot read property 'splice' of undefined. and is not able to drop the element. Need help on how to resolve this problem.

Below is the html part

    <table class="table">
        <thead class="text-primary">
            <tr>
                <th>Task ID</th>
                <th>Ref #</th>
                <th>Customer Name</th>
                <th>Doc Type</th>
                <th>Date</th>
            </tr>
        </thead>
        <tbody [dragula]='"team-bag"' [dragulaModel]="tasks">
            <tr *ngFor="let t of tasks">
                <td>{{t.id}}</td>
                <td>{{t.refNbr}}</td>
                <td>{{t.custName}}</td>
                <td>{{t.docType}}</td>
                <td>{{t.receiveDate}}</td>
            </tr>
        </tbody>
    </table>
    
        <table class="table">
        <thead class="text-primary">
            <tr>
                <th>Task ID</th>
                <th>Ref #</th>
                <th>Customer Name</th>
                <th>Doc Type</th>
                <th>Date</th>
            </tr>
        </thead>
        <tbody [dragula]='"team-bag"' [dragulaModel]="agentATasks">
            <tr *ngFor="let t of agentATasks">
                <td>{{t.id}}</td>
                <td>{{t.refNbr}}</td>
                <td>{{t.custName}}</td>
                <td>{{t.docType}}</td>
                <td>{{t.receiveDate}}</td>
            </tr>
        </tbody>
    </table>

tasks and agentATasks are both defined and populated in the component.ts.

Below is the error in Chrome console. Subscriber.ts:241 Uncaught TypeError: Cannot read property 'splice' of undefined at Object.eval (http://localhost:3002/node_modules/ng2-dragula/components/dragula.provider.js:94:28) at emitter (http://localhost:3002/node_modules/contra/emitter.js:47:72) at Array.forEach (native) at Object.eval (http://localhost:3002/node_modules/contra/emitter.js:46:10) at Object.thing.emit (http://localhost:3002/node_modules/contra/emitter.js:38:48) at drop (http://localhost:3002/node_modules/dragula/dragula.js:261:13) at HTMLHtmlElement.release (http://localhost:3002/node_modules/dragula/dragula.js:245:7) at ZoneDelegate.invokeTask (http://localhost:3002/node_modules/zone.js/dist/zone.js:265:35) at Object.onInvokeTask (http://localhost:3002/node_modules/@angular/core/bundles/core.umd.js:5967:41) at ZoneDelegate.invokeTask (http://localhost:3002/node_modules/zone.js/dist/zone.js:264:40)

user1214916
  • 209
  • 1
  • 12
  • Did you get any solution, I am getting the same error – codeomnitrix Aug 08 '17 at 07:03
  • I'm also getting the same issue. Using copy= true which works fine when dragulaModel is not set. – Bradley Morris Aug 09 '17 at 19:14
  • 1
    Any fix you got for this, I m trying to use same in mine Angular5 app, getting the same error, however, following the same way what they have mentioned in there doc... wondering how it is working for them. – nitin Apr 24 '18 at 06:57

0 Answers0