Closed IgoPeg closed 7 years ago
Solution:
resolve: function (errorType, el) {
var parameter = el.attr('ng-' + errorType);
if (parameter === undefined) {
parameter = el.attr('data-ng-' + errorType) || el.attr(errorType);
}
parameters.push(parameter || '');
return $translate('FORMS.' + errorType).then(function (ms) {
return ms.replace(/{(\d+)}/g, function (match, number) {
return typeof parameters[number] !== undefined ? parameters[number] : match;
});
});
}
When i use the myCustomErrorMessageResolver that returns a promise example:
.factory('myCustomErrorMessageResolver', [ '$translate', function ($translate) { 'use strict'; return { resolve: function (errorType) { return $translate('FORMS.' + errorType); // will return "Bitte eine Zahl von mindestens {0} eingeben." } }; } ])
The {0} will not replaced by specific value. Example on ng-minlength="6"