Skip to content

Make content projection selectors more lenient #16017

@SvenBudak

Description

@SvenBudak

For example i tryed to pass a own component as mat-card-avatar into the <mat-card-header>:

<mat-card-header>
    <app-image class="mat-card-avatar"></app-image>
    <mat-card-title>Name</mat-card-title>
    <mat-card-subtitle>Subtitle</mat-card-subtitle>
</mat-card-header>

But this dont work, because <mat-card-header> allow only his own sub components on correct place: https://github.com/angular/components/blob/master/src/material/card/card-header.html

<ng-content select="[mat-card-avatar], [matCardAvatar]"></ng-content>
<div class="mat-card-header-text">
  <ng-content
      select="mat-card-title, mat-card-subtitle,
      [mat-card-title], [mat-card-subtitle],
      [matCardTitle], [matCardSubtitle]"></ng-content>
</div>
<ng-content></ng-content>

Please add [.mat-card-avatar] as class to line 1.
Would be good if this is possible in every material component.

The current solution looks like:

<mat-card-header>
    <div mat-card-avatar>
        <app-image class="mat-card-avatar"></app-image>
    </div>
    <mat-card-title>Name</mat-card-title>
    <mat-card-subtitle>Subtitle</mat-card-subtitle>
</mat-card-header>

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: material/cardfeatureThis issue represents a new feature or feature request rather than a bug or bug fixneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions