$setValidity in directive and 'validationErrorKey'
1,985 views
Skip to first unread message
Adriaan Bouman
unread,
Aug 1, 2012, 4:51:24 AM8/1/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
Hi all,
I am using the following in my custum input directive: controller.$setValidity(false); As result the input and form gets invalidated, as I was hoping for!
In the documentation and API it says I need to supply a 'validationErrorKey'. Is this really needed or is the above also a valid practise?
Thanks for clarifying!
greetings,
Adriaan
Pawel Kozlowski
unread,
Aug 31, 2012, 1:50:24 PM8/31/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
hi!
On Wed, Aug 1, 2012 at 10:51 AM, Adriaan Bouman
<adriaan...@gmail.com> wrote:
> Hi all,
>
> I am using the following in my custum input directive:
> controller.$setValidity(false); As result the input and form gets
> invalidated, as I was hoping for!
> In the documentation and API it says I need to supply a
> 'validationErrorKey'. Is this really needed or is the above also a valid
> practise?
'validationErrorKey' is really needed as soon as you want to display
precise error messages to your users. The 'validationErrorKey' makes
it possible to distinguish different validation errors for the same
field (for example: id a field is required and of type email you might
have 2 error conditions: the field not filled in at all or provided
value not being a valid email). So yes, I would say it is pretty much
mandatory to provide 'validationErrorKey' if you want your directive
to be really user-friendly. Check the syntax for validation error
here: http://docs.angularjs.org/api/ng.directive:input