简体   繁体   中英

ngModel controller, $$updateEventHandler is undefined

i'm currently porting the development environment from gulp to webpack with out angularjs and react hybrid app.

the application is huge. 10mb of files at the moment.

but i am currently encountering some issues. this line: this.$$updateEventHandler = this.$$updateEventHandler.bind(this); which is inside the main angular.js file.

and the error is state like this:

TypeError: Cannot read property 'bind' of undefined at ngModel.controller.NgModelController (angular.js:29413)

which I interpreters as $$updateEventHandler is the one that is not defined, and that is the case too when I put a breakpoint on the line and checks it inside devtools.

I've also tried to update angularjs and right now i am running the 1.7.0 version, before I've tried both 1.2, 1.3, 1.4.5 and 1.6.10 but the same error occurrs everywhere.

also, i've searched the web but couldnt find anything related to this, which makes me think that this is just a plain stupid mistake by me somewhere, but i'ev tried to solve it now for 6 hours, and now i put all my hopes into you dear stackoverflowers!

In my case I was experiencing such an error in a decorator after update:

$provide.decorator('ngModelDirective', ['$delegate', function($delegate) {
var ngModel = $delegate[0], controller = ngModel.controller;
ngModel.controller = ['$attrs', '$injector', function( attrs, $injector) {
  attrs.$set('name', 'custom');
  $injector.invoke(controller, this, {
    '$attrs': attrs
  });
}];
return $delegate;

}]);

You should attach prototype of NGModel controller to the context. You may use Object.setPrototypeOf(obj, prototype).

 $provide.decorator('ngModelDirective', ['$delegate', function($delegate) {
var ngModel = $delegate[0], controller = ngModel.controller;
ngModel.controller = ['$attrs', '$injector', function( attrs, $injector) {
  attrs.$set('name', 'custom');
  $injector.invoke(controller, Object.setPrototypeOf(this, controller.prototype), {
    '$attrs': attrs
  });
}];
return $delegate;

}]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM