ngMessages is not working as expected
I am using ngMessage with angular material. But it doesn't working as expected. I have my code here.
The problem is once the error message is displayed, when another new error is appeared and the existing error is disappeared then it breaks. For above example, click on the input and click outside of it. You will receive the required error. Now when you try inserting any character, the required error disappeared and the email error should appear. But this is not working.
<div ng-app="app" ng-controller="FormController" layout-padding>
<form name="inputForm">
<md-input-container>
<label>Input Value</label>
<input type="email" name="email" ng-required="true" ng-pattern="/^.+@.+\..+$/" ng-model="model.value" />
<div ng-messages="inputForm.email.$error">
<div ng-message-exp="['required', 'pattern']">E-mail is not valid</div>
</div>
</md-input-container>
<div>inputForm.inputValue.$error = {{inputForm.email.$error | json}}</div>
</form>
</div>
I have the same issue with the newest update of material and angular
Another issue here is that error message does not show initially for required input field.
on the last bit, I think it is by design... I have discussed this with users a number of times, and they don't seem to like being presented with error messages until they at least enter something, so the idea that ng-messages are hidden until the related field has been $touched seems good to me.
Messages that should be displayed even before the user interacts with a field seem to me to be labels or input hints.
Same issue here on ng-material 1.0.0, 1.0.1 and angular 1.4.6 and 1.4.8.
Update: adding md-auto-hide="false" solves my problems. I can now add ng-show="form2.username.$touched" to hide on page load and voila, I'm golden.
@FrancescoRizzi: I thought so. At least we need a way to enable this. And suggestion from @rsteenbergen is exactly what we need. This is also described in docs.
I think the hide animation works after the element appears into the display section. So it hides all messages. Is there any way to solve the issue temporarily?
@rsteenbergen thanks - that helped me
NgMessage behave erratically with angular-material. Here is a plunker: http://embed.plnkr.co/SWJFsOS3BuxYxePBQZ0C/
It works fine with just the required validation check, but if I add another, like min for instance, then sometimes the error message isn't shown at all.
Without angular-material it works fine.
Form Without Angular-Material
Initial

When I enter a value < 400:

Form With Angular-Material
I enter a small value:

I erase everything:

I enter a value greater than 400 and then erase everything:

UPDATE: Fixed it thanks to @rsteenbergen, linked plunker now has updated code.
So this is resolved?
Well @rsteenbergen provided a workaround, but is that the solution we want? Shouldnt it 'just work' with ngMessages instead of users having to add rsteenbergen's solution.
I'm seeing the same problem and agree with @joerideg . It is erratic so I hesitate to use the md-hide workaround to get it to work more often.
Update: While I have noticed strange behavior with the appearance of the messages, this time it was my mistake. I accidentally left off the input's name attribute. Sorry!
Using md-auto-hide="false" isn't a great fix, since all errors will display by default, which can be overwhelming for someone filling out a new empty form.
I have the same problem here with angular 1.5.0 and angular-material 1.0.5. Also after I updated angular-material from 1.0.1 the error pushes content down instead of appearing in md-errors-spacer
you can see it's even in official demo https://material.angularjs.org/latest/demo/input
Confirming this too (angular 1.5.0 + angular-material 1.0.5).
Any fix on this?
+1
+1
same here
+1