validation errors in md-autocomplete
I want to configure a md-autocomplete input as required and show a message if not filled, but it's not working
<md-autocomplete name="autocompleteName" ... >
</md-autocomplete>
<div ng-messages="form.autompleteName.$error">
<div ng-message="required">This is required!</div>
</div>
if I inspect the formController object for the form, there isn't any object for autocompleteName
any hint? any help? I just want to validate the md-autocomplete following as the same way of the inputs, is it possible?
made my own autocomplete component, which links ng-messages into it
Just, I can do it too, but I would prefer to follow the "standard" way like the others inputs
@javierpavon2000 I prefer that too, but the md-autocomplete is inconsistent with md-input, that's I really don't like.
@hitigon Agreed on it's inconsistency with md-input. Seems like it is currently designed to resemble a md-select instead of a md-input. It looks really odd with other md-input elements around it.
@hitigon @javierpavon2000 @bfelda I just added a styling option for use in standard forms: f487248a70c9bfd749953e98e3412240112f39a3
I will be adding validation support as well.
A demo of the new styles can be seen here: https://material.angularjs.org/#/demo/material.components.autocomplete
@robertmesserle awesome job!
Proposed syntax for ng-messages:
<md-autocomplete md-search-text="searchText" required>
<md-item-template>...</md-item-template>
<div ng-messages="searchText.$error">
<div ng-message="required">This field is required</div>
</div>
</md-autocomplete>
Please, can you make some example with validations ? And what is md-item-template ?
+1 for md-autocomplete validation example with md-item-template
+1 with validation example
+1
@robertmesserle This looks great! Thanks for implementing it.
@bfelda this is going to be solved in 0.9.0?
@gpopovic This is not going to be in 0.9.0, but I submitted a Pull Request for this feature: https://github.com/angular/material/pull/2664
:+1:
+1
At master, still no validation for md-autocomplete. The example doesn't work.
Opened a new issue for this bug since it still appears to be broken: #3401
Yes that's it. It's not working for md-autocomplete validation:
