Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular translate directive not working with ngMessage

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.

like image 263
Alexander Avatar asked Sep 04 '14 11:09

Alexander


Video Answer


1 Answers

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>
like image 135
Alexander Avatar answered Oct 11 '22 15:10

Alexander