Expand my Community achievements bar.

Ternary Sightly Condition is not working

Avatar

Level 3

Hi Team,

              I have to display the current page title on the basis of checkbox value and in else condition i need to display deafult vale.

I tried  but it is not working it is act as string 

title:${properties.pagetitle ?'currentPage.title':' properties.headline'}

it display me currentPage.title

 

is there anything wrong in the syntax.

5 Replies

Avatar

Employee Advisor

Hi @savi50 ,

Yes there is syntax error (Do not use inverted commas inside {}), please use as : 

${properties.pageTitle? currentPage.title : properties.headline}

Thanks

Avatar

Level 3

Hi @milind_bachani ,

                      I already tried above but it is giving error 

${properties.pagetitle ?currentPage.title:properties.headline}: mismatched input '}' expecting {'.', 'in', '&&', '||', '[', ':'}

Avatar

Level 1

Please separate ternary operators with a white-space to provide clarity to the parser. In your case this would be where the colon `:` is used:

 

${properties.pageTitle ? currentPage.title : properties.headline}

You may also want to confirm your letter-casing and scope (component vs page).

Avatar

Employee Advisor

Please use proper spacing before and after the operators ( ? : )and then try. 
I also reverified the same on my local it works fine when I use something like :

${properties.prop1 ? properties.prop1 : currentPage.pageTitle}
OR
${properties.prop1?properties.prop1 : currentPage.pageTitle}

But, gives a blank page when I do 

${properties.prop1 ? properties.prop1:currentPage.pageTitle}

Hence, please check the whitespaces.