Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created May 11, 2015 20:40
Show Gist options
  • Select an option

  • Save ajcrites/94a8674117b5aad764f0 to your computer and use it in GitHub Desktop.

Select an option

Save ajcrites/94a8674117b5aad764f0 to your computer and use it in GitHub Desktop.
ng-class="{ 'with-border': dash.showBorder, 'without-border': !dash.showBorder }

You can also do borderClass and set it as a string or something like that. Presentationally-specific names are discouraged such as those including "border" in the name of any symbols (css class or variable).

So just as an example, say that they decide rather than a border style change they want a background color style change. Only the presentation has changed, so you could just update the border rule in the CSS to a background-color rule and be fine -- but currently all your symbols would be wrong, i.e. with-border would not specify any border rules.

I suggest: .hasDaysLeft and .noDaysLeft

Great, but has-days-left etc. preferred

oh so - and not camelCase. cool

For CSS classes yes. Reasoning behind that is case-insensitivity of html in addition to dashes being valid in html symbol names and css selectors.

@gotoplanb
Copy link

👍

@firoze
Copy link

firoze commented May 11, 2015

after another suggestion from Andrew, I switched it from that "2 class 1 boolean" in the ng-class directive to just setting ng-class to point to a string variable, and setting the class name there. made code easier to read, and added flexibility for more classes in the future (Y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment