-
Notifications
You must be signed in to change notification settings - Fork 58
route with forms in ng-view getting error "Cannot set property '$validationSummary' of undefined" #58
Comments
Hello Rob, I can't reproduce any of your errors 1 or 2, but in order for me to fix these Does it give you any other functionality issues, or is it simply the fact that it throws errors in the console? If it's just JS console errors, then it's easy to fix, I would simply check if variable is not null before querying it or whatever else is needed. Let me know |
It is not just console errors. I've put back back in the validation summary display stuff of the outer controller and field. I've added second route, and defaulted to First route, now a console error occurs immediately on page load [not surprising to me]. Note that if you add a char to Field1 error goes away, but the template field value of Field1 jsut above is not displayed between the [[]] markers, removing a character only restores the red box when you leave the field it does not restore the error message below Field1, And the error on clearing FIeld1 only gets applied when leaving Field1 not after timeout. So something is not running any more I think. The case at work is stopping the route view from changing properly between views, and it is occurring when we switch between routes without any other inputs, so that both the before and after views are visible in the view. I have not been able to get that to happen in this example so far. Oops updated the demo a bit. Rob. |
Ok so here is what I found so far, you are using 3 different VMs and you expect them to be completely independent but it doesn't look like they are. I just added a couple of Hmmm ok I think I found the problem, this problem will most probably only show up when using the |
LOL. I just came back to this page to re read what i wrote to see if i had missed something, and saw your reply appear... Anyway ouch that sounds like it might be a chunk of work to clean up. |
Yeah OOP in javascript is still a little bit of a pain and it looks like I didn't fully understand it, I'll have to review all my code. Considering that we'll eventually have to use TypeScript for Angular 2.0, that would have probably helped in my situation :S |
Angular 2 is very different beast, i suspect its a re-engineer from ground up no path of migration except for concepts. I hope to use React some time soon, I've been tinkering with it, and so much stuff is just simpler. |
I changed a lot of code to make the Now the only 2 options that I see that would work, but are really not interesting:
Actually thinking about it while writing, there might be another option, I could rollback everything and make it the way it was and possibly add a new Global Options being |
It's fixed now, I ended up staying with variables that are shared with Directive & Service (hence the word But you have to know that your code was actually divided in 2 problems which I fixed: For the problem 2), I added a new Global Options that you need to use to fix this issue. The new option is var vm = this;
var v1 = new validationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false }); You can see the Global Options for this new option of Looks like you'll need to pay a beer, after so many code change for you, next time I visit Australia again :P |
Had a bit of a play, looks decent, I can't use it in our problem area at the moment as we are in count down to a release, and can't afford to reset some of the testing progress. Cheers Rob. |
I have a hiccup at work, and have been trying to reproduce it.
Interaction of routes with validation, I think it might be tied up with $destroy of scopes, but not sure.
This example is not the same behaviour I have at work but this is related.
It is similar as it is the same error message 1. below.
There is a chance I have just mucked my code and so its my bug not one in angular-validation, but I think I have squashed most of the dumb out of the example now.
http://plnkr.co/edit/c94r1xA8e0M3iXnWCe6w?p=preview
Load the demo, then click in FIeld1 and click out no error.
Load the demo, then click in Field1 and type a letter no error.
Now click on "First" next to "Choose Route" this activates the route.
Now two errors occur.
"TypeError: Cannot set property '$validationSummary' of undefined"
"Uncaught TypeError: Cannot read property 'isValidationCancelled' of null"
Sometimes I can get error case 1. without typing anything into field one, but its hit and miss and not frequently.
If line 37 is commented out - "var v = new validationService()", then error 1 does not happen, but 2. still does.
Cheers, Rob.
The text was updated successfully, but these errors were encountered: