Skip to content

Feature: @Directive should support styles and styleUrls properties #17766

@SchnWalter

Description

@SchnWalter

I'm submitting a ...


[ ] Regression (behavior that used to work and stopped working in a new release)
[ ] Bug report 
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently, if you have a @Directive that requires some custom styles you have to deal with the inclusion of styles, the @Directive does not accept styles and styleUrls (and maybe encapsulation: None|Emulated).

Expected behavior

The DirectiveResolver should accept styles, styleUrls (and encapsulation: None|Emulated) for the @Directive decorator.

What is the motivation / use case for changing the behavior?

/**
 * Removes the spacing around an `md-list` component when it is a child of `md-card`.
 */
@Directive({
  selector: 'md-list[my-md-list-in-card]',
  styles: [`
    md-list[my-md-list-in-card] {
      .mat-list-item-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
      }
    }
  `]
})
export class MyMdListInCardStylerDirective { }

Metadata

Metadata

Assignees

Labels

area: coreIssues related to the framework runtimecore: stylesheetsfeatureLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under consideration

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions