0

I would like to style a couple of elements using a filter to decipher if it should be yellow or red.

I understand filters should not carry logic operations in them as such so am guessing a service is the first port of call before i create any filter for it.

I am leveraging data from a backend (still a bit unsure of the Backend model here, but know I can leverage certain objects to obtain the data needed for working on) I mostly need to know if i`m on the right path by using a service to control the logical outcome and then a filter to provide 'filtration' of that outcome.

BTW: sorry, im waiting for my project to checkout from SVN at mo so cannot provide a skeleton attempt. Will do in a bit though ..... Any advice before hand will be much appreciated :) Gruffy - thanks for reading

1
  • Are you referring to view styling with filter. Better way would be to use ng-style or ng-class Commented Oct 14, 2014 at 10:37

1 Answer 1

1

You can directly set the class attribute if you want, so your filter can simply return the CSS class to apply:

<p class="{{'foo'|myFilter}}">Foo</p>

Here's a fiddle showing what I mean.

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

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.