How do we check input element's  *$erro*r on blur to display an appropriate 
error message based on *minlength, maxlength, required, pattern, etc...?*



On Thursday, December 12, 2013 8:01:26 PM UTC-6, Daniel Tabuenca wrote:
>
> I don't think it is documented anywhere other than in the code. Looking at 
> the code it looks like actually it doesn't set a priority so it should be 
> default priority of 0. This means setting your directive priority to just 1 
> should do the trick.
>
>
> On Thursday, December 12, 2013 3:51:29 PM UTC-8, Khanh Nguyen wrote:
>>
>> I did not know about the priority.  So how do you know built-in directive 
>> having a priority of 100?
>>
>> On Monday, December 9, 2013 4:25:10 PM UTC-6, Daniel Tabuenca wrote:
>>>
>>> That’s not the reason. It doesn’t matter what you name the controller 
>>> parameter in the link function, you could name it 
>>> theControllerForTheDirectiveNgModel and it would still work. The 
>>> problem is that the order that priority is applied has changed causing 
>>> Vojta’s directive to execute before the built-in input directive. You need 
>>> to make sure the new directive has larger priority so that it will execute 
>>> after the built-in. Since built-in directive has a priority of 100, adding 
>>> a priority of 101 will make sure it executes after and make everything work 
>>> as expected.
>>>
>>> On Monday, December 9, 2013 1:38:00 PM UTC-8, Khanh Nguyen wrote:
>>>
>>> Never mind.  I found that ngModelCtrl has been changed to 
>>>> ngModelController in 1.2.x.
>>>>
>>>> Thanks for creating  a directive like that.
>>>>
>>>> On Monday, December 9, 2013 3:23:43 PM UTC-6, Khanh Nguyen wrote:
>>>>>
>>>>> Vojta,
>>>>>
>>>>> Do you know why the directive you created above would not work with 
>>>>> the latest AngularJS 1.2.x?
>>>>>
>>>>> Thanks,
>>>>> Khanh
>>>>>
>>>>> On Sunday, April 15, 2012 3:06:04 PM UTC-5, Vojta Jína wrote:
>>>>>>
>>>>>> Yes
>>>>>>
>>>>>> On Sun, Apr 15, 2012 at 7:53 PM, Peter Bacon Darwin <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> In the order given by the priority?
>>>>>>>
>>>>>>>
>>>>>>> On 15 April 2012 19:14, Vojta Jína <[email protected]> wrote:
>>>>>>>
>>>>>>>> All directives are executed.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sat, Apr 14, 2012 at 12:49 PM, Peter Bacon Darwin <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> OK I get it.  Two questions:
>>>>>>>>>  - Are there ever any times when you would want an invalid model 
>>>>>>>>> value?  I guess not - at least I can't think of any right now.  If 
>>>>>>>>> there 
>>>>>>>>> were some complex validation that relied on other inputs or state 
>>>>>>>>> this 
>>>>>>>>> would be done outside parsers?
>>>>>>>>>  - I am interested in the way you override input in the app 
>>>>>>>>> module.  What does this do to the ng-input directive?  Are both 
>>>>>>>>> directives 
>>>>>>>>> executed?  Or is it last declared wins?
>>>>>>>>> Pete
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  On 14 April 2012 13:28, Vojta Jína <[email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> We do validation on model update, because you want to have your 
>>>>>>>>>> the valid. (invalid view does not update model).
>>>>>>>>>>
>>>>>>>>>> You can override input directive, to use "blur" event:
>>>>>>>>>> http://jsfiddle.net/JYTUB/1/
>>>>>>>>>>  
>>>>>>>>>> V.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, Apr 12, 2012 at 7:00 AM, Peter Bacon Darwin <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> This is becoming a recurring theme. I wonder if model changes 
>>>>>>>>>>> are actually the best place for validation? Given the wide range of 
>>>>>>>>>>> requirements perhaps an event based mechanism would be more 
>>>>>>>>>>> flexible and 
>>>>>>>>>>> perform faster.
>>>>>>>>>>> My idea would be that every input directive would trigger events 
>>>>>>>>>>> such as select,  change or blur. You then set up the form to 
>>>>>>>>>>> trigger 
>>>>>>>>>>> validation based on these events asking all the directives whether 
>>>>>>>>>>> the are 
>>>>>>>>>>> valid. Reasonable defaults should mean that most cases would work 
>>>>>>>>>>> without 
>>>>>>>>>>> unwanted declarations but that social cases can be configured on a 
>>>>>>>>>>> form by 
>>>>>>>>>>> form basis.
>>>>>>>>>>> Pete
>>>>>>>>>>>
>>>>>>>>>>> ...from my mobile.
>>>>>>>>>>> On Apr 12, 2012 2:04 PM, "Pawel Kozlowski" <
>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> hi!
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, Apr 12, 2012 at 2:54 PM,  <[email protected]> 
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> > So is it possible to get the directive called just then when 
>>>>>>>>>>>> I loose focus?
>>>>>>>>>>>> > I don't want to get the directive called after the the first 
>>>>>>>>>>>> entry in the
>>>>>>>>>>>> > field! Just after I inserted e.g '2,11'...
>>>>>>>>>>>>
>>>>>>>>>>>> OK, I didn't realize that you want to validate just after 
>>>>>>>>>>>> completing
>>>>>>>>>>>> all the input. There was a recent change when ngModelInstant 
>>>>>>>>>>>> was added
>>>>>>>>>>>> back and forth but ultimately was removed in rc4
>>>>>>>>>>>> (
>>>>>>>>>>>> https://github.com/angular/angular.js/blob/master/CHANGELOG.md#1.0.0rc4
>>>>>>>>>>>> )
>>>>>>>>>>>> as several people were rising concerns about it (search the 
>>>>>>>>>>>> mailing
>>>>>>>>>>>> list history for model instant to see the history).
>>>>>>>>>>>>
>>>>>>>>>>>> Honestly, with the ngModelInstant removed (and binding behaving 
>>>>>>>>>>>> like
>>>>>>>>>>>> ngModelInstant by default) I'm not sure what would be the 
>>>>>>>>>>>> proper way
>>>>>>>>>>>> of triggering the validation only after control is loosing the
>>>>>>>>>>>> focus...
>>>>>>>>>>>>
>>>>>>>>>>>> Cheers,
>>>>>>>>>>>> Pawel
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> You received this message because you are subscribed to the 
>>>>>>>>>>>> Google Groups "AngularJS" group.
>>>>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>>>>> To unsubscribe from this group, send email to 
>>>>>>>>>>>> [email protected].
>>>>>>>>>>>> For more options, visit this group at 
>>>>>>>>>>>> http://groups.google.com/group/angular?hl=en.
>>>>>>>>>>>>
>>>>>>>>>>>>  -- 
>>>>>>>>>>> You received this message because you are subscribed to the 
>>>>>>>>>>> Google Groups "AngularJS" group.
>>>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>>>> To unsubscribe from this group, send email to 
>>>>>>>>>>> [email protected].
>>>>>>>>>>> For more options, visit this group at 
>>>>>>>>>>> http://groups.google.com/group/angular?hl=en.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  -- 
>>>>>>>>>> You received this message because you are subscribed to the 
>>>>>>>>>> Google Groups "AngularJS" group.
>>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>>> To unsubscribe from this group, send email to 
>>>>>>>>>> [email protected].
>>>>>>>>>> For more options, visit this group at 
>>>>>>>>>> http://groups.google.com/group/angular?hl=en.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  -- 
>>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>>> Groups "AngularJS" group.
>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>> To unsubscribe from this group, send email to 
>>>>>>>>> [email protected].
>>>>>>>>> For more options, visit this group at 
>>>>>>>>> http://groups.google.com/group/angular?hl=en.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "AngularJS" group.
>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>> To unsubscribe from this group, send email to 
>>>>>>>> [email protected].
>>>>>>>> For more options, visit this group at 
>>>>>>>> http://groups.google.com/group/angular?hl=en.
>>>>>>>>
>>>>>>>
>>>>>>>  -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "AngularJS" group.
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To unsubscribe from this group, send email to 
>>>>>>> [email protected].
>>>>>>> For more options, visit this group at 
>>>>>>> http://groups.google.com/group/angular?hl=en.
>>>>>>>
>>>>>>
>>>>>> 

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to