Reputation: 2249
I have a form object and I need to check if the value of a field is equal a certain string
I'm trying this but it is not working
@if(sp.pageType.equals("customreCare")) {
//render this specific div
} else {
//render this other div
}
but unfortunately it is not working, what is the syntax for that?
Upvotes: 7
Views: 7382
Reputation: 55798
Use ==
operator for comparing strings:
@defining("something") {whatToTest =>
@if(whatToTest == "something"){ There is something } else { There is.... nothing }
}
so in your case (of course make sure that there are no typos in the conditions like customreCare
...):
@if(sp.pageType == "customreCare") {
//render this specific div
} else {
//render this other div
}
Upvotes: 10