How to add attr without value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to add attr without value

Neha k
Hi
I am new to the thymeleaf and working on project of AngularJS.
I have to add directive into the html tag but whenever i want to achieve the following its throw exception ..

<input enroll type="text" />

exception : org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as assignation sequence

I try the following..

<input th:attr="enroll"  type="text" />

Using the template mode html5.

Please tell me is this correct way if not how to add the attribute without any =value.?
Please help me asap. Thanks.


 
Reply | Threaded
Open this post in threaded view
|

Re: How to add attr without value

danielfernandez
Administrator
As of today, Thymeleaf uses a tuned XML-based parser underneath, so it won't allow you to specify attributes without a value (this will change in 3.0).

The workaround is adding a value to your attribute. The default is to use as value the name of the attribute itself. Your AngularJS code will work 100% OK:

    <input enroll="enroll" type="text" />

(Note you can also use an empty value, like enroll="", but IMHO this is less elegant, and less standard)
Reply | Threaded
Open this post in threaded view
|

Re: How to add attr without value

Neha k
Thank you !! thats works.