0

I have a variable defined in my AngularJS that counts the length of my array e.g. "array.length". I want to pass this into my LESS file as a variable e.g. @length = "array.length" so that I can use it change another class or variable...

Is this possible? If so how?

1
  • what do you want to do in your css with the array.length variable? Commented Nov 6, 2013 at 0:46

2 Answers 2

1

AngularJS executes within the browser. LESS is processed on the server, before it is sent to the browser. So, there is no direct way of accessing an AngularJS variable from LESS.

The best way forward, most likely, would be to set some CSS properties directly within the javascript code based on array.length.

Sign up to request clarification or add additional context in comments.

1 Comment

You can also use LESS on the client side but I wouldn't recommend it for production.
0

There is no such thing, as explained by Jim Garrison. You could always use ng-class, however. It is a directive you can use for setting a CSS class through AngularJS; in this way you can choose which class you want to use for your element, and update it via AngularJS listeners.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.