--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
It’s a bit more tricky. But you can do it like this:
var ngModel = ngModelDirective[0];
//Save old controller it's actually at index 5 due to injection array syntax
var oldController = ngModel.controller[5];
//Override controller
ngModel.controller = function($scope, $exceptionHandler, $attrs, $element, $parse){
//Let the old controller do it's thing
oldController.apply(this, arguments);
this.$setValidity = jasmine.createSpy();
//Save the controller to the test variable
ngModelController = this;
};
http://plnkr.co/edit/B37j6Xjl0HmFjVKAGJq0?p=preview
I’m not sure if this is the best or recommended way of doing it, but it works. Can anyone think of an easier way?