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 to clone an element using class name and append it to the body

    How to rotate text and position it properly? (CSS, HTML)

    How to apply class only for IE?

    How to implement this kind of blur effect?

    CSS: how to move element from one column to another one without changing the html?

    how to relocation dropdownmenu by CSS

    Divs are overlapping, how to fix? CSS

    How can I align an image with css

    How to write persistent CSS box rules?

    How to completely remove borders from HTML table

    How to center text in lists?

    how to remove the last li::after for first line in specific width of an div

    How to add a ToolTip for an icon inside my CSS file

    How to use same header for multiple page inside same html file

    How to make somethings like this in CSS?

    How do i make a flexible div with a background in css

    How to place two canvases adjacent to each other and on top of a third one

    How to stretch full height of a div using CSS? [closed]

    How to add animated gif to an image sprite?

    how to override min-width

    How to override default css style rule of Bootstrap

    Nth-child css property is counting html elements with display property set to none. How to change it?

    jQuery & CSS - How to stop a relative element from floating left and right (when you're scrolling)?

    How does the padding work in responsive CSS square?

    How to change in all css “#xxx” to “#000” [closed]

    How/where to center Items on Webpage

    How do I vertically centre a div of variable height within a div of variable height?

    How to ensure three DIV are the same height regardless of content

    How to animate my element in my case?

    How to style multiples of 3 li elements [duplicate]