Q1. Suppose I want to alter the look of each "item" that a user marks for deletion before the main "delete" button is pressed. (This immediate visual feedback should eliminate the need for the proverbial "are you sure?" dialog box.) The user will check checkboxes to indicate which items should be deleted. If a checkbox is unchecked, that item should revert back to its normal look.
What's the best way to apply or remove the CSS styling?
Q2. Suppose I want to allow each user to personalize how my site is presented. E.g., select from a fixed set of font sizes, allow user-definable foreground and background colors, etc.
What's the best way to apply the CSS styling the user selects/inputs?
One more (in the future) way to conditionally apply style is by conditionally creating scoped style
But nowadays only FireFox supports scoped styles.
This works well when ng-class can't be used (for example when styling SVG):
(I think you need to be on latest unstable Angular to use ng-attr-, I'm currently on 1.1.4)
I have published an article on working with AngularJS+SVG. It talks about this issue and numerous others. http://www.codeproject.com/Articles/709340/Implementing-a-Flowchart-with-SVG-and-AngularJS
You can use ternary expression. There are two ways to do this:
or...
and code
css
well i would suggest you to check condition in your controller with a function returning true or false .
and in your controller check the condition
As of AngularJS v1.2.0rc,
ng-class
and evenng-attr-class
fail with SVG elements (They did work earlier, even with normal binding inside the class attribute)Specifically, none of these work now:
As a workaround, I've to use
and then style using