Material: ng-messages doesn't hide when input is valid

Created on 8 May 2015  路  14Comments  路  Source: angular/material

The message should be hidden once there is some input in the field.

bildschirmfoto vom 2015-05-08 11 51 53
bildschirmfoto vom 2015-05-08 11 50 50

important fixed docs

Most helpful comment

I had similar issue. I just added ngMessages dependency in module in app.js. Solved my problem.

All 14 comments

I found out that when using <ng-message> as element instead of an attribute, it works as expected:

  <md-input-container flex>
    <label translate>First Name</label>
    <input name="firstName" ng-model="person.firstName" required>
    <div ng-messages="personEdit.firstName.$error">
      <ng-message when="required" translate>This field is required.</ng-message>
    </div>
  </md-input-container>

Is this a material or angular bug?

It's not entierly obvious when reading the documentation, but you need ngMessages for errors, as can be seen here: https://material.angularjs.org/#/api/material.components.input/directive/mdInput. If that's not the problem, what version of angular are you using?

That was the problem, many thanks for the hint!

This "ng-message" is used as an attribute on angular material demos https://material.angularjs.org/latest/demo/input

I had similar issue. I just added ngMessages dependency in module in app.js. Solved my problem.

Just add ngMessages directly in your module.

This works.

:)

Fixed my issue too - thank you!

Fixed my issue too, thank you very much

Why Not add this part to documentation?

Sometimes I also don't read all.
capturar

Same issue with attribute directive don't seem work.

I resolved like told by
"smehrbrodt commented on 8 May 2015

Using element instead attribute all work like a charm

(using angular 1.5.8)

It is also stated in the documentation of ng-input:

Notes:

this definitely should be highlighted better in the documentation.how about a

<h1> tag to the explanation?

This is now also part of the blank shell CodePen in the "Getting Started" Guide and there is a section in the same guide that breaks down the optional dependencies.

Was this page helpful?
0 / 5 - 0 ratings