0

Let say I have a Angular app with directives like so:

<!doctype html>
<html lang="en" ng-app="cfd">
  <head>
    ...
  </head>
  <body>
    <div class="container">    
      <!-- Header -->
      <div ui-view="header" class="row"></div>

      <div ui-view="main" class="row">
        <!-- Sidebar/Nav -->
        <div ui-view="sidebar" class="col-xs-3"></div>
        <!-- Content -->
        <div ui-view="content" class="col-xs-9"></div>
      </div> 

      <!-- Footer -->
      <div ui-view="footer" class="row"></div>
    </div>
  </body>
</html>

How do I apply CSS to a directive using the Angular directive handle ui-view or any other custom directive, without adding an HTML ID handle. SO for the "main" section, I dont want the following: <div id="main" ui-view="main" class="row">.

I have tried .ui-view#main and ui-view#main.

0

1 Answer 1

2

If I understand correctly, you want to use the angular directive ui-view as identifier in your CSS?

In your CSS file, you could potentially use

div[ui-view=main] {
    /* styles for main go here, duh! */
}

Seems to work in Chrome (http://plnkr.co/edit/r1fvheUs8S6AJHv4Dm59?p=preview)

If you want conditional styles, you should use

<div ng-class="{'className': 'angular condition'}"></div>
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.