Skip to content

Commit

Permalink
Merge pull request #184 from huei90/compile
Browse files Browse the repository at this point in the history
Add $compile to output html
  • Loading branch information
Huei Tan committed Jan 4, 2016
2 parents 6658730 + 7763e58 commit 051e0d5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 9 deletions.
10 changes: 6 additions & 4 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You can also add a `validation-group` directive to group many elements into a gr
```html
<label>Validation group</label>
<!-- Group both of these elements inside the contact group -->
<input type="text" name="email" ng-model="email" validator="required" validation-group="contact">
<input type="text" name="email" ng-model="email" validator="required" validation-group="contact">
<input type="number" name="telephone" ng-model="telephone" validator="number" validation-group="contact">
<!-- The message will be placed in side the span element -->
<span id="contact"></span>
Expand Down Expand Up @@ -248,10 +248,14 @@ in `getDefaultMsg()`,and finally return the HTML code
$validationProvider.setErrorHTML(function (msg) {
// remember to return your HTML
// eg: return '<p class="invalid">' + msg + '</p>';
// or using filter
// eg: return '<p class="invalid">{{"' + msg + '"| lowercase}}</p>';
});

$validationProvider.setSuccessHTML(function (msg) {
// eg: return '<p class="valid">' + msg + '</p>';
// or using filter
// eg: return '<p class="valid">{{"' + msg + '"| lowercase}}</p>';
});
}]);
```
Expand Down Expand Up @@ -282,7 +286,7 @@ The built in `maxlength` and `minlength` validators use parameters to configure
<input type="text" name="username" ng-model="form.username" validator="maxlength=6"/>
```

You can use parameters in your custom validators in the same way.
You can use parameters in your custom validators in the same way.
You can access this parameter in the validation expression like so:

```html
Expand Down Expand Up @@ -358,5 +362,3 @@ angular.module('yourApp', ['validation'])
};
}]);
```


5 changes: 3 additions & 2 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
var $validationProvider = $injector.get('$validation');
var $q = $injector.get('$q');
var $timeout = $injector.get('$timeout');
var $compile = $injector.get('$compile');
var $parse = $injector.get('$parse');

/**
Expand All @@ -387,7 +388,7 @@
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showSuccessMessage && messageToShow) {
messageElem.html($validationProvider.getSuccessHTML(messageToShow));
messageElem.html('').append($compile($validationProvider.getSuccessHTML(messageToShow))(scope));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
Expand Down Expand Up @@ -425,7 +426,7 @@
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showErrorMessage && messageToShow) {
messageElem.html($validationProvider.getErrorHTML(messageToShow));
messageElem.html('').append($compile($validationProvider.getErrorHTML(messageToShow))(scope));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/validator.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var $validationProvider = $injector.get('$validation');
var $q = $injector.get('$q');
var $timeout = $injector.get('$timeout');
var $compile = $injector.get('$compile');
var $parse = $injector.get('$parse');

/**
Expand All @@ -31,7 +32,7 @@
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showSuccessMessage && messageToShow) {
messageElem.html($validationProvider.getSuccessHTML(messageToShow));
messageElem.html('').append($compile($validationProvider.getSuccessHTML(messageToShow))(scope));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
Expand Down Expand Up @@ -69,7 +70,7 @@
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showErrorMessage && messageToShow) {
messageElem.html($validationProvider.getErrorHTML(messageToShow));
messageElem.html('').append($compile($validationProvider.getErrorHTML(messageToShow))(scope));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
Expand Down
Loading

0 comments on commit 051e0d5

Please sign in to comment.