문제

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?

도움이 되었습니까?

해결책

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
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top