Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i'm trying to figure out how to bind angularjs scope vars into external css file the problem i think is the curly braces here is what i'm basically trying to do:

.css_class {background:{{ angular_variable }}; color:#ffffff;}

I found a similar question here but the solution corresponds to inline css, but what if we need to externalize the template and the css properties?

share|improve this question
add comment

1 Answer

I'm afraid at the moment that is not possible but last commit for angularjs added support for expresssions in style tags.

So you can do things like that:

In your controller:

$Scope.mystyles = {
 .myclass: {
  display: block
 }
};

In your html:

<style>{{mystyles}}</style>

angularjs changelog

Take into account that it won't work in IE8 though, since it's been deprecated from 1.3.x.

share|improve this answer
 
Well frankly not bothered about IE but it still feels a hack, though thank you. –  Uday Reddy yesterday
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.