Hey,

What do you mean when you say "I can't use css"? Why can't you? If you save 
the currently active item somewhere you can use `ng-class` to selectively 
add a style for the active item. You can also use `ng-style` with an 
expression, but I dislike it for the same reason I prefer not to use the 
style attribute at all in templates.

Anyway, of course you can create a directive to do it. Your directive will 
just need to look for when the item becomes selected and change the CSS 
class accordingly. Here's 
<http://plnkr.co/edit/0pN3QdKZWERsA41YWKXB?p=preview> an example.

On Tuesday, September 29, 2015 at 9:24:44 PM UTC+3, Tim Wheeler wrote:
>
> I'm converting a jQuery app to Angular and I keep fight the tendency to do 
> "jQuery things".  
>
> I have an unordered list (multiple actually) that serve as filters to a 
> dataset using ng-repeat.
>
> When I select one of the list items I want to change the background-color 
> of the li element (really change the style).
>
> I can't use css to do this so I'm thinking it has to be some directive.  
>
> Has anyone seen any samples how a person might do this?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to