Skip to content

mat-optgroup does not support ng-container child wrapper #9736

@Londovir

Description

@Londovir

Bug, feature request, or proposal:

mat-optgroup does not support using an immediate child of ng-container (which, in turn, has the immediate mat-option child). This is in cases where it it desired to *ngFor loop over the master group array, then *ngFor loop over children of each group, but only include certain children using *ngIf subject to some property of the child; since you cannot use both *ngFor and *ngIf on the same element (mat-option). Using ng-container as the wrapper for the group children is more convenient than writing additional component logic to dynamically manipulate the arrays.

What is the expected behavior?

mat-optgroup respects ng-container for the immediate child so that this sort of layout logic is possible.

What is the current behavior?

Although no console error is thrown, the children are not parsed and displayed [at all]. Only the mat-optgroup labels are shown in the mat-select.

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

Follow this StackBlitz: Reproduction case

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular: 5.1.2
Material: 5.1.1
OS: win 10 x64
TypeScript: 2.5.3
Browsers: Chrome, Edge, etc.

Is there anything else we should know?

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions