-
Notifications
You must be signed in to change notification settings - Fork 174
Open
Labels
Description
Situational
- ✓ Allow compilation for the output html in i18n case Able to compile validation output message? (template validation message) #96
- ✘ Support i18n - $translate.instant - angular-translate #176 AngularJS i18n support #177
- Able to use $http in the setExpression case / Backend Validation
✓ Compilation
Able to use filter and directive in the html
$validationProvider.setErrorHTML(function (msg) {
return <span> {{ msg | translate }} </span>;
});$validationProvider.setErrorHTML(function (msg) {
return <custom-bar msg=msg />;
});But this $compile will make the application more heavier.
Code given in this PR
✘ angular-translate
$validationProvider.setErrorHTML(function (msg) {
return <span> this.$injector.get('$translate').instant(msg) </span>;
}This is better and convenient stuff, use when you need it.
Not support $injector at this moment, use filter
$http/Backend Validation
Although we can easily setup setExpression and angular-validation support $q for the validation
But in the case doing backend validation, it's a plus if we can use $http inside the setExpression which used in config phase (we are not able to inject $http in config)
$validationProvider.setExpression({
email: function (value) {
var $http = $injector.get('$http');
$http.get(url, value)
.success()
.error()
});
});Fix it
- Compilation for the output html - This is what angularjs way, should compile before every template
- adding $injector for the provider. - is this a good practice in angularjs?
Conlusion
We need to cover all the situations to provide more async/advanced validation.