angularjsng-messages

Angular ng-messages, errors, warnings and form validity


Is there a angular (1.4+) way with ng-messages to show warnings and errors the difference being that warnings don't make the form invalid but the errors do so the user can save the form even though there are warnings? Searched all over and can't seem to find anything about this though I think it should be an obvious part of the system o_O


Solution

  • Judging from the Ng-Messages Docs I don't believe that is possible.

    When you include the ng-messages onto an html element they will hide or show that element based on the $error object in the form field. You can create custom errors if you like, but if triggered they will always make the form invalid.

    To get around this you could write something to watch a user's input and have a bootstrap warning message set to conditionally appear if the conditions are met, but not have that be in any ng-messages html element.