Uncaught TypeError: Object #<Object> has no method 'forEach'" line no-239
anjanjis opened this issue · 4 comments
I am using bindonce in phonegap Android App and getting an error "object has no method forEach". I am using bindonce with Angular 1.2.13.
03-01 04:14:28.944: I/chromium(1397): [INFO:CONSOLE(239)] "Uncaught TypeError: Object # has no method 'forEach'", source: file:///android_asset/www/lib/bindonce.js (239)
I am using angular-loader and script.js for loading angular modules asynchronously.
please suggest what was the caused?
Indeed it seems that bindonce is loaded before angular is properly initializated. Can you check the bootstrap of your application?
Following is the bootstrap of my application
$script([
'phonegap.js',
'cordova_plugins.js',
'js/index.js',
'lib/jquery-1.10.2.min.js',
'lib/angular/angular.min.js',
'lib/angular/angular-animate.min.js',
'lib/angular/angular-resource.min.js',
'lib/angular/angular-touch.min.js',
'lib/angular/angular-route.min.js',
'lib/mobile-nav.js',
'lib/bindonce.js',
'js/app.js',
....
], function() {
// when all is done, execute bootstrap angular application
angular.bootstrap(document, ['myApp']);
app.initialize();
$script.js loads the files asynchronously so in any order as quickly as possible and while the angular-loader prevent to get the 'module undefined' error it doesn't create the real angular object therefore angular.forEach is an nonexistent function.
I'll fix this error in the next version in order to handle the asynchronous load properly, until then you can force bindonce to delay its execution/load, $script supports this use case with the function .ready().
Facing the same problem. As you said there are workarounds but I was wondering if you have any plans on releasing the new version with this bug fix any time soon.
Cheers