Skip to content

binding classes for component activated by router-outlet #49483

@KingMario

Description

@KingMario

Which @angular/* package(s) are relevant/related to the feature request?

router

Description

For an Angular UI library like Clarity, regarding the application layout, .content-container class is required for the top level route components.

I'd like to propose a feature request about binding classes for component activated by router-outlet.

Proposed solution

Add an @Input() componentClass = '' to router-outlet directive.

Aafter this.activated is initialized, add the classes to the created or attached component as following:

  this.activated.location.nativeElement.classList.add(...this.componentClass.split(' '));

Alternatives considered

Currently, as mentioned above, for each route component, the following codes should be added in the @Component metadata:

  host:  {
    '[class.content-container]': 'true',
  },

Adding componentClass to router-outlet solves it more directly and concisely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routerfeatureIssue that requests a new featurefeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions