Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated validate directive to compile the error and success html strings (useful for translation keys) #97

Closed
wants to merge 2 commits into from

Conversation

jamhall
Copy link

@jamhall jamhall commented Mar 17, 2015

Added compile service to compile the error and success strings.

For example, you may wish to use translation keys for the error and success messages:

  app.config(['$validationProvider', '$parseProvider', function ($validationProvider) {
    var expression = {
      required: function (value) {
        return !!value;
      }
    };

    var defaultMsg = {
      required: {
        error: 'generic.form.validations.required.error',
        success: 'generic.form.validations.required.success'
      }
    };

    $validationProvider.setExpression(expression).setDefaultMsg(defaultMsg);

    $validationProvider.setErrorHTML(function (msg) {
      var html = "<span class=\"label label-danger\">{{ '{0}' | translate }}</span>".replace('{0}', msg);
      return html;
    });

    $validationProvider.setSuccessHTML(function (msg) {
      var html = "<span class=\"label label-success\">{{ '{0}' | translate }}</span>".replace('{0}', msg);
      return html;
    });
}]);

Please note, I have built it using the grunt build task but I have not commited the build files.

Cheers,

Jamie

Added compile service to compile the error and success strings
@jamhall
Copy link
Author

jamhall commented Mar 17, 2015

Reference: #96

@jamhall jamhall changed the title Updated validate directive to compile the error and html strings (useful for translation keys) Updated validate directive to compile the error and success html strings (useful for translation keys) Mar 17, 2015
@hueitan
Copy link
Owner

hueitan commented Mar 19, 2015

Hi @jamhall Thanks for this.

Would you mind do grunt build on this?

@jamhall
Copy link
Author

jamhall commented Mar 19, 2015

Added :-)

@hueitan
Copy link
Owner

hueitan commented May 11, 2015

Close it. Open if needed.

@hueitan hueitan closed this May 11, 2015
@hueitan
Copy link
Owner

hueitan commented Nov 26, 2015

You are right. I'm thinking about this fix now, it make more sense to us using angular compile.

Thanks @jamhall I would like to accept the PR now.

Sorry for the delay.

@hueitan
Copy link
Owner

hueitan commented Jan 4, 2016

New PR here.
#184

@hueitan hueitan closed this Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants