来自 AngularJS 示例的简单输入:
<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>
当您输入大于 5 的值时,应该可以看到翻译后的错误消息。当我使用翻译指令时它不起作用。