question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting TypeError: Illegal invocation with ngf-drop

See original GitHub issue

I am using version 4.1.4 with the following HTML snippet to support collection of files:

`

<div id="designFileDropArea" ngf-drop ng-model="designFiles" class="col-md-6 dropArea" ngf-drag-over-class="dropHover" ngf-multiple="true" ngf-allow-dir="false" ngf-accept="'*.doc,*.docx,*.xls,*.xlsx,*.pdf'" ngf-hide-on-drop-not-available="true" style="margin: 0em 0em 1em 1em;"> Drop file(s) here </div>

`

Unfortunately, this generates errors when dropping a file during assignment to the ng-model:

`TypeError: Illegal invocation at equals (angular.js:1034) at equals (angular.js:1019) at Scope.$get.Scope.$digest (angular.js:15550) at Scope.$get.Scope.$apply (angular.js:15824) at angular.js:17580 at completeOutstandingRequest (angular.js:5370) at angular.js:5642(anonymous function) @ angular.js:12221$get @ angular.js:9055$get.Scope.$digest @ angular.js:15574$get.Scope.$apply @ angular.js:15824(anonymous function) @ angular.js:17580completeOutstandingRequest @ angular.js:5370(anonymous function) @ angular.js:5642 angular.js:12221

TypeError: Illegal invocation at equals (angular.js:1034) at equals (angular.js:1019) at Scope.$get.Scope.$digest (angular.js:15550) at Scope.$get.Scope.$apply (angular.js:15824) at NgModelController.$$debounceViewValueCommit (angular.js:24919) at NgModelController.$setViewValue (angular.js:24891) at ng-file-upload.js:547 at angular.js:17571 at completeOutstandingRequest (angular.js:5370) at angular.js:5642(anonymous function) @ angular.js:12221$get @ angular.js:9055$get.Scope.$digest @ angular.js:15574$get.Scope.$apply @ angular.js:15824NgModelController.$$debounceViewValueCommit @ angular.js:24919NgModelController.$setViewValue @ angular.js:24891(anonymous function) @ ng-file-upload.js:547(anonymous function) @ angular.js:17571completeOutstandingRequest @ angular.js:5370(anonymous function) @ angular.js:5642 angular.js:12221

TypeError: Illegal invocation at equals (angular.js:1034) at equals (angular.js:1019) at Scope.$get.Scope.$digest (angular.js:15550) at Scope.$get.Scope.$apply (angular.js:15824) at angular.js:17580 at completeOutstandingRequest (angular.js:5370) at angular.js:5642(anonymous function) @ angular.js:12221$get @ angular.js:9055$get.Scope.$digest @ angular.js:15574$get.Scope.$apply @ angular.js:15824(anonymous function) @ angular.js:17580completeOutstandingRequest @ angular.js:5370(anonymous function) @ angular.js:5642 44angular.js:12221

TypeError: Illegal invocation at equals (angular.js:1034) at equals (angular.js:1019) at Scope.$get.Scope.$digest (angular.js:15550) at Scope.$get.Scope.$apply (angular.js:15824) at tick (angular.js:10983)(anonymous function) @ angular.js:12221$get @ angular.js:9055$get.Scope.$digest @ angular.js:15574$get.Scope.$apply @ angular.js:15824tick @ angular.js:10983 `

What am I doing incorrectly?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
skidvdcommented, May 29, 2015

I have resolved my issue. Several problems in combination led to it:

  1. don’t use both ng-model and ngf-change in combination with each other … choose one approach
  2. Build up a list of files in a separate scope variable
  3. don’t use a regular $watch with objectEquality true if you need to watch the $scope variable containing list of files, it leads to Illegal Invocation errors - still not entirely sure why on that front. Turns out thought that $watchCollection does not produce this error (why does watch???) … and appears to work as desired in this case
  4. while not part of the problem, it led to some confusion, don’t attempt to JSON.stringify a file object

plunk updated to reflect working approach

0reactions
bradiosdcommented, Jul 4, 2016

I had an issue with this error when using deep watching too. I stored the temporary files against an array 3 levels deep under a watched object and causes this area. To fix this I now store my files against it’s own variable separately. It’s not the best way of fixing as my files are now delinked from the actual object I am affecting but it will work. Thanks for the help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng-file-upload getting TypeError: Illegal invocation with ngf-drop
The TypeError: Illegal invocation occurs when adding a $watch with objectEquality set to true on a model which contains a file(s) property used...
Read more >
Angularjs – ng-file-upload getting TypeError: Illegal invocation with ...
The TypeError: Illegal invocation occurs when adding a $watch with objectEquality set to true on a model which contains a file(s) property used...
Read more >
How do I pass an image from ajax to nodejs ( illegal ...
So i am trying to upload an image from frontend(html) and save it locally , get the path and save the path into...
Read more >
Illegal invocation` when working with angularJS, angular ...
... 'template': '<button ngf-select ng-model="myFile">Select file</button>' ... you will get the // TypeError: `Illegal invocation` instead store the copy ...
Read more >
password match validation in angular - You.com
Directives get translated in the view from valueMessages => value-messages ... <div *ngIf="confirmPassword.touched && confirmPassword.invalid" class="alert ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found