Angular translate directive not working with ngMessage
Asked Answered
O

1

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.

Onlybegotten answered 4/9, 2014 at 11:23 Comment(1)
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: <div ng-message="max">{{'FORM.MAXVALUE' | translate}}</div>Univalence
O
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>
Onlybegotten answered 8/9, 2014 at 6:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.