pertrai1
pertrai1

Reputation: 4328

Adding a css class to Angular Directive Element

I have a directive <my-directive> that is an element. I do not use link or compile, just:

export default function myDirective() {
    return {
        restrict: 'E',
        scope: true,
        templateUrl: 'my-directive.html',
        controller: mydirective,
        controllerAs: 'mine',
        bindToController: {}
    }
}

This of course is a fake directive, but the issue I have is being able to add a css class on this directive when it is in the DOM.

if there is anymore information I need to add, please let me know.

Upvotes: 0

Views: 887

Answers (1)

santialur
santialur

Reputation: 235

You could target the directive's tag from your CSS/scss stylesheet, this way:

Say you have:

<mydirect></mydirect>

So in styles.css:

mydirect {
  background-color: red;
}

Upvotes: 2

Related Questions