Track tasks and feature requests
Join 40 million developers who use GitHub issues to help identify, assign, and keep track of the features and bug fixes your projects need.
Sign up for free See pricing for teams and enterprisesFeature Request: Dynamically add ng-message to ng-messages #10036
Comments
This comment has been minimized.
This comment has been minimized.
|
I'm not sure why you'd need this, since we already have async validation, so you could just set up a message for the particular async error you're validating against. While we could allow you to add new messages, I feel like it would make the API cumbersome, so we'd have to think about this. @petebacondarwin / @matsko thoughts? |
caitp
added
component: forms
component: ngMessages
severity: confusing
frequency: low
labels
Nov 13, 2014
caitp
added this to the
Backlog milestone
Nov 13, 2014
This comment has been minimized.
This comment has been minimized.
|
From my understanding if the error message itself comes from the backend async validation doesn't help. Sounds pretty limiting to me to only define the list of error message in HTML. Not sure what this modification implies but shouldn't be hard to add add/remove/modify message functions. |
This comment has been minimized.
This comment has been minimized.
|
@adrianandreias @caitp I think having dynamic messages is a great idea. The problem is that we can't use something like ng-repeat since there would be a conflict over how the elements are entered and removed from the ng-messages container, but if we can get that to work then it would open up a bunch of possibilities. I think it would be better if we keep as much of the message handling as possible in the HTML instead of having an imperative solution then we can do a lot more stuff. It would be ideal if we could have something like: <div ng-messages="myForm.myField.$error">
<div ng-message="required">You did not enter a field</div>
<div ng-message="key" ng-repeat="(key, message) in remoteMessages">
{{ message }}
</div>
</div>@adrianandreias would this work for you? |
This comment has been minimized.
This comment has been minimized.
|
Sure, I assume we can have If this is the whole idea it's perfect. (btw @matsko I love your site!) |
This comment has been minimized.
This comment has been minimized.
jessemorton
commented
Dec 23, 2014
|
I'd love to see this as well. There's plenty of cases where an async validator is impractical/overkill for all the fields in a form, but that it'd be desirable to display backend errors if they arise upon form submission. |
petebacondarwin
assigned
matsko
Dec 24, 2014
petebacondarwin
modified the milestones:
1.4.x,
Backlog
Dec 24, 2014
petebacondarwin
added
frequency: moderate
and removed
frequency: low
labels
Dec 24, 2014
This comment has been minimized.
This comment has been minimized.
|
@matsko is going to work to support this in 1.4 |
This comment has been minimized.
This comment has been minimized.
wendellmva
commented
Jan 3, 2015
|
Bah Bah, I was trying to get this to work the whole day, thinking it was me. My forms are build completely at runtime by meta data so yeah I need it. Thanks! |
This comment has been minimized.
This comment has been minimized.
|
Here's a work in progress: http://plnkr.co/edit/EqxV25DMumMR9fPiBdnZ?p=preview |
This comment has been minimized.
This comment has been minimized.
|
@adrianandreias @jessemorton @wendellm this feature now exists in a PR and it's tested and functional, but we're just taking this week to decide on a proper naming convention. |
This comment has been minimized.
This comment has been minimized.
jessemorton
commented
Jan 14, 2015
|
Thanks @matsko! |
This comment has been minimized.
This comment has been minimized.
|
That's great @matsko :) |
This comment has been minimized.
This comment has been minimized.
|
Will this be included in 1.4? |
This comment has been minimized.
This comment has been minimized.
|
The goal is to have it for both 1.3 and 1.4 so long as it doesn't break anything. |
This comment has been minimized.
This comment has been minimized.
|
I think this didn't make it into v1.4.0-beta.2 and v1.3.10, right? |
This comment has been minimized.
This comment has been minimized.
|
Not yet. Still negotiating a proper naming convention. |
This comment has been minimized.
This comment has been minimized.
|
We're almost there. Just waiting on a final review for #10676. |


adrianandreias commentedNov 13, 2014
Add the ability to programaticaly add ngMessage item to an existing ngMessages directive.
I am trying to show the field error returned by an AJAX form submit. This way frontend errors and backend errors displaying would be done the same way.
Do you this is the right approach or you would just create another way to insert the server side error in the DOM?