You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
I just read the blotpost at yearofmoo about ngMessages. I think the module is a welcome addition but I find that the first available beta has certain gaps. //cc @matsko
Primarily, the validation jumps the gun kicking in as soon as I start editing the field. Say for email, obviuosly email is not going to be valid for the first several characters I type.
The way I used to solve it, is hooking into onblur, so that the user only sees the error once they move to the next field.
For things like checking username/passwords through a remote API call I always use $timeout so that I don't hammer the API as the user is typing, and I don't distract them with useless messages as they are doing so. Again, some built in support in the module would be highly desirable.
Clicking the submit button should call the submit() function only if the validation passes. Otherwise it should only trigger (re)validation of the form.
I'm happy to discuss this further is there are any questions, or to split that into three separate issues if that's preferred.
The text was updated successfully, but these errors were encountered:
The forms in Angular are being reworked a bit, but ngMessage is solely there for displaying messages. The core is being fixed to allow for more flexibility with when the errors are updated.
Debouncing can be used if you want the errors to only update once the input field is blurred (look at ngModelOptions).
AngularDart has a $submitted property which will be brought into AngularJS soon. For now, with ngMessages, it's best to use your own submitted variable, but once this is in then you won't need to, but you'll still need an ngIF. I think the long term goal is to have debouncing determine exactly when the errors are updated upon submit. There will also be a $touched property (which is called when the input field is blurred or when the form is submitted).
Also #7377 introduces a better validation system which can you can call explicitly.
1/ and 2/ are addressed in 1.3.-beta builds with ngModelOptions.
3/ depends a lot on the validation style you want to use in your app. #7377 might help here, but even without it, in the submit callback you can check if the whole form is valid. If it is, move on. If it's not, display validation messages and abort submit. In most apps we want to provide the validation feedback sooner than on form submit, so this should not be the default behavior.
I think these issues have been largely addressed in 1.3. I am going to close this, but if there's still some case that ngMessage doesn't handle well, feel free to file another issue @kkozmic.
I just read the blotpost at yearofmoo about ngMessages. I think the module is a welcome addition but I find that the first available beta has certain gaps. //cc @matsko
The way I used to solve it, is hooking into
onblur
, so that the user only sees the error once they move to the next field.$timeout
so that I don't hammer the API as the user is typing, and I don't distract them with useless messages as they are doing so. Again, some built in support in the module would be highly desirable.submit
button should call thesubmit()
function only if the validation passes. Otherwise it should only trigger (re)validation of the form.I'm happy to discuss this further is there are any questions, or to split that into three separate issues if that's preferred.
The text was updated successfully, but these errors were encountered: