How to provide an API to alter CSS / styles / white label for an encapsulated angularJS directive ( re usable widget / component )


Tags: css,angularjs,widget,angularjs-directive,white-labelling

Problem :

In my journey to understand directives and after looking on http://ngmodules.org/ and considering the re usable component / widget model.

A question i have is how would you / whats the best way to provide an API for a hosting application to alter the CSS of an encapsulated widget.

So we have widget A ...

Basic structure

Module Service Model Controller Directive etc

Any events from the component / widget are emited in order to provide loose coupling

We dont want a dependency on a CSS library like bootstrap so we want to be able to provide an api to allow the hosting application to white label the look and fell to be more in line with itself.

How would you / what is the best way to do this ?



Solution :

I wasn't sure if you're looking to provide default styling within a directive or whether you want the flexibility to apply styling on a directive from a client application.

CSS and styles can be applied on a directive when it is declared. The CSS/Style rules are "passed" into the directive and depending on how your directive template is defined, will automatically be applied to the underlying template. If you want more specific control of CSS/styling, you can use the passed in attributes parameter in a compile or link function to indicate where you want the styling to specifically occur.


    CSS Howto..

    How do I set the width and height of a textarea using CSS?

    How to create two column in form using css

    In a responsive layout how can I get divs to shrink uniformly?

    How can i display all buttons to right in bootstrap panel heading?

    how to align elements using css in angular typeahead

    CSS: How to do image change on rollover

    How to display .entry-content CSS on Wordpress home page?

    CSS: how to make a span only as wide as its content

    How to fixed the form fields alignment issues using css and bootstrap

    CSS how do I define the height between multiple label and textboxes elements

    How would I set this up? [closed]

    How to add specific CSS attributes to all text-containing elements

    How to hide a div in the Repeater

    How to make hyperlink for a background image?

    How can I set the System.Web.Optimization bundler to correctly transform ISO unicode

    How to prevent bootstrap css class to override my custom css class

    section to be trigger of show/hide content by click html/css only

    How do i place 4 headers from 1 div next to each other?

    How to remove all elements except for one, maintaing the same CSS path to it?

    How to set the width of a jQuery Mobile 1.4 responsive Panel in percentage?

    CSS how to align vertically center div floating elements of menu?

    CSS Transition - how to make a text coming from the top side?

    How to access CSS generated content with JavaScript

    how to hide html video controls in micorostf edge (fullscreen mode)

    How to top-level a rich:panelMenu with it's rich:outputPanel with an h:panelGrid?

    jQueryUI tabs mouseover a disabled link, how do I change the cursor so it doesn't appear clickable?

    How To Refer To CSS Background Image in Visual Studio?

    How to make device width-height based html & css via PhoneGap

    How do I filter unwanted CS styles from CS sheet?

    diagonal lines as background for css - how to switch angle