6

Simple input from an AngularJS example:

<body ng-controller="myappCtrl">
<form name="myForm">
  <label>Enter your number:</label>
  <input type="number" name="myNumber" ng-model="name" min="{{minvalue}}" max="{{maxvalue}}"/>
  <pre>myForm.myNumber.$error = {{ myForm.myNumber.$error | json }}</pre>
  <pre>myForm.$valid = {{ myForm.$valid | json }}</pre>

  <div ng-messages="myForm.myNumber.$error" style="color:red">
    <div ng-message="number">You did not enter a valid number</div>
    <div ng-message="min">Your field value is lesser minimum value</div>
    <div ng-message="max" translate="FORM.MAXVALUE"></div>
  </div>

</form>

link to plnkr

When you enter a value higher than 5 a translated error message should be visible. It does not work when I use the translate directive.

T J
  • 42,762
  • 13
  • 83
  • 138
Alexander
  • 3,019
  • 1
  • 20
  • 24
  • Seems to be a bug. Maybe with the angular-translate directive. Please report this on the angular-translate github site. A workaround you can use now:
    {{'FORM.MAXVALUE' | translate}}
    – Martin Sep 04 '14 at 11:35

1 Answers1

11

From the angular translate github:

That's an issue with multiple scopes, you have to wrap it.

 <div ng-message="max"><span translate="FORM.MAXVALUE"></span></div>
T J
  • 42,762
  • 13
  • 83
  • 138
Alexander
  • 3,019
  • 1
  • 20
  • 24