Alexander Alexander - 2 months ago 4x
AngularJS Question

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>


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.


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>