如何解决使用 angular-translate 进行角度形式的验证消息翻译
我正在尝试在 formlyjs
中翻译 angularjs
所需的验证消息,这是我尝试过的代码,但它没有翻译或将翻译后的字符串带入“required " 我正在使用 angular-translate。
输出 我得到的是 Usernamerequired
而不是 Username is required
我已经看过这个问题并回答了 stackoverflow。它不需要 to.label
但我需要这个 to.label
连接。
请提供任何帮助或建议。
$translateProvider.translations("en",{
required: "is required",})
formlyValidationMessages.messages.required = 'to.label + "required" | translate';
angular.module('templates/formly/validation-messages.html',[]).run([
'$templateCache',function ($templateCache) {
$templateCache.put('templates/formly/validation-messages.html','<formly-transclude></formly-transclude>' +
'<div class="validation-messages" ng-messages="(fc[0] || fc).$error" ng-if="(options.formControl[0] || options.formControl).$touched || (options.formControl[0] || options.formControl).$error.required || form.$submitted" ng-messages-multiple>' +
' <div class="label label-danger animate vanishIn enter-vanishIn exit-vanishOut" ng-message="{{::name}}" ng-repeat="(name,message) in ::options.validation.messages">' +
' {{message((fc[0] || fc).$viewValue,(fc[0] || fc).$modelValue,this)}}' +
' </div>' +
'</div>' +
'');
}
]);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。