Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Validation message not showing on ng-repeater after back navigation. #137

Closed
caseyoconnor opened this issue Nov 10, 2016 · 3 comments
Closed

Comments

@caseyoconnor
Copy link

First, thank you for writing this library.

We have an ng-repeater with (n) columns wide and a few rows. Each column has an input element that can be updated, thus it needs validation. When we navigate to a new route and then either click the browsers back button and or ng-click back to the route the validation occurs but the div below does not show.

Field is required.

We have tried to use the validation-error-to directive and explicitly added a div in hopes that this would be a work around but it was not a successful attempt.

Below I have made a plunker that begins on the "Home" view then navigates to "People" with a repeater and then on to an "Away" route. If you run the plunker and you click to the Away route and then go back you will notice when you clear out the input field that the validation message does not show. However the validation message will show before you $state.go to another route.

https://plnkr.co/edit/AvazGJNmbjR1x2T4RMfS

While making the plunker and simply using window.location.href = 'http://www.google.com'; I was able to navigate back and I believe the validation message fired.

This leads me to wonder if the combination of angular-ui-router with the ghiscoding-validation is the issue?

@ghiscoding
Copy link
Owner

Hmm I have noticed this in the past, but never got time to debug it. It might be a timing issue, there's so many timing issue in Angular that's it's annoying sometime to debug. Also, I can see that the ValidationSummary doesn't get filled in correctly either (it works on first load but not after leaving and coming back). You can see the summary by adding this

<div class="alert alert-danger alert-dismissable">
    <ul>
        <li ng-repeat="item in validationForm.$validationSummary">{{item.field }}: {{item.message}}</li>
    </ul>
</div>

I seriously don't know when I'll have time to debug this. I'm trying to work on some other things in my free time. However, that seem to be where to start

@ghiscoding
Copy link
Owner

ghiscoding commented Dec 14, 2016

Hello and sorry for the delay, I am planning on passing more time in resolving some of these issues during my upcoming Christmas holiday. I was looking at some of my Global Options available and just remember that I have an option called resetGlobalOptionsOnRouteChange Wiki - Global Options that is specifically used with the regular Angular Route, that is used in the validation-common.js file at line 24.

Would you be able to use the unminified version of Angular-Validation and change that line 24 with the UI Router watch and see if that makes any difference? Specifically, change the line 24 from $rootScope.$on("$routeChangeStart" to $rootScope.$on("$stateChangeStart"

I will probably need another Global Option asking which Router has the user setup in his project and make the regular Angular Route as default.

@ghiscoding
Copy link
Owner

Actually this was bothering me too much, so I made a quick change in my code (I added a second watch for UI Router), ran all my Protractor tests and pushed a quick version 1.5.10 and that seem to have fixed the issue in the Plunker you provided.

I will close this issue for now since I think that it's fixed (if not, I can re-open it).
Please confirm, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants