-
Notifications
You must be signed in to change notification settings - Fork 176
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
Able to compile validation output message? (template validation message) #96
Comments
Hi @jamhall I prefer not to do this in the validation method. We should handle this on the javascript function, not in angular way. I'm going to close this, open it if needed. |
Hello, could you be a bit more explicit please? Got a work around for
|
Users should have the ability to use a custom template. You allow custom
|
Hi @jamhall In your example, you are using You can do the same using javascript function $validationProvider.setErrorHTML(function (msg) {
return "<span class=\"label label-danger\">" + translate(msg) + "</span>";
});
// ...
function translate (msg) {
// get translation data dictionary
// ... blablabal translate
return translate_msg;
} |
Let me think about this. |
Your example would not work because the template is not parsed :(
|
What's the meaning of "the template is not parsed" ? In the source code, It's just output a html code only. messageElem.html($validationProvider.getSuccessHTML(messageToShow)); I suppose that output validation message should be simple, therefore I didn't involved compile here. |
But that's the point. If you cannot use a custom template, then you cannot use any template functions. You have put this function:
This would not work. You cannot call a modules function in the Most angular modules allow a template to be parsed. I don't see why this is a problem for you? |
And by parsing I mean something like this:
Why, with your current module am I unable to call template functions? |
Hi @jamhall Thanks for reaching this question. Seems in your case you need those "template" like validation message, I think it's needed to compile if we provide template validation. But for now, validation message is simple and plain, maybe next version we can have the message in template for more customisation 😄 . Add this as enhancement. |
@jamhall You do not need to compile the HTML for translation, you can call it programmatically. Just put up a commit for this.
for using filters you can inject the $filter and use any filter you like as:
|
@Nazanin1369 nice fix. Let's consider both solutions. |
@Nazanin1369 - I feel that I don't like to put code like that into my template strings. I honestly don't see what the problem is, and why this is being over-complicated, the solution that I have offered is clean and is only a couple of lines of code and it also doesn't depend on any other dependencies. I've looked at your commit, you're injecting the translate module, why? Not everyone will be using the translation module... it should be optional. If I were to use your commit, I wouldn't be able to update the angular-validation module with any changes. I'd like to stick to main source tree. Also, it's unnecessary, if the template string is compilled, then I can just call the Have you looked at my PR? The point is, people should be able to use a validation template like a normal template without resorting to hacks. Thank you! Apologies for the delay in replying....currently on holiday. |
Hi @jamhall Sorry for nudging you back to this topic and I also want to apologize to you that your suggestion is not that bad. {{ msg | translate }} is a lot cleaner than this.$injector.get('$translate').instant(msg) Totally Agree.
Usually in angularjs, we want to do a lot of compilation, even though the directive itself, so the compilation for the output html template is needed.
Yes, we haven't merged that commit yet because we have some concern, here's the discussion board #178
Since I haven't closed this issue because I though this may have some serious discussions in some days and we are seriously thinking about this now. Hope you can understand and continually giving us more suggestions and directions. Sorry for putting you in this situation and I know we have the discussion about $injector before which we had some agreements. Let's rethinking about this, hopefully, we can sketch up the final answer. |
@huei90 - thanks for your prompt reply
I still don't understand why this needs to be continually discussed. What's the problem? It's a simple and transparent change. It doesn't break anything. It doesn't change anything for existing users and it adds needed functionality. Why discuss this further? I appreciate you want to open and transparent....but this functionality was asked for (and the code was provided) nine months ago... |
@jamhall You are right, this change doesn't break anything and I also hope this can be merged soon.
Sorry again @jamhall, we take every commits/issues seriously so that I can't make an immediate decision by my own. There are something we should do before merging
Please give us some time and you will see the merging soon 🍻 |
@huei90 - Ok, excellent. thank you for clearing that up. I look forward to seeing the changes in the near future. 🍻 |
You will see this soon. You have my word 😄 |
@jamhall You are compiling againts the $rootScope which triggers a digest cycle on clients app from the root to last child scope which is a performance hit. |
@Nazanin1369 I'm going to merge this feature |
New pr created here. |
Hello,
Great module!
I would like to translate the default messages for example, I have this:
Please note that
generic.form.validations.required
is a translation key.It would be nice if this module could interpolate the error html so I have the translated message.
Any ideas to solve this?
Thanks!
The text was updated successfully, but these errors were encountered: