-1

I am having angular variable in my html page. when I am using {{myVar}} , it is showing the data. I need to use this variable in sightly condition below:

<ul class="${ dropdownList.index == {{myVar}} ? '' :  display_none'}">

I am getting error when using {{myVar}} or myVar in the condition please help.

Manan Kapoor
  • 675
  • 1
  • 11
  • 28

3 Answers3

4

HTL/Sightly is a server-side template system and cannot evaluate client-side (Angular) variables.

Vlad
  • 10,602
  • 2
  • 36
  • 38
0

You are mixing two completely different template languages running in two completely different environments. Sightly -> backend scripting language, AngularJS -> frontend scripting language. So use Sightly to render your AngularJS template feeding it with not changing data and in the opposite get your dynamic data with AngularJS depending on the client context as soon as the page loads. So if you need to evaluate some expression dynamically (not while the page is server side rendering), you should write this logic competely in AngularJS. You can check this answer for that what you are looking for. Alternative if you don't want to provide AngularJS template, just to render once your drop down as you need, than just replace {{myvar}} with your server side variable holding that data.

d33t
  • 1,143
  • 6
  • 15
-1
<ul ng-class="{ dropdownList.index == {{myVar}} ? '' :  display_none'}">

This would work for you.

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57