Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to use ng-container within mat-grid-list #12809

Closed
tbnovaes opened this issue Aug 23, 2018 · 4 comments · Fixed by #12823
Closed

not able to use ng-container within mat-grid-list #12809

tbnovaes opened this issue Aug 23, 2018 · 4 comments · Fixed by #12823
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@tbnovaes
Copy link

Bug, feature request, or proposal:

Allow ng-container to work inside mat-grid-list

What is the expected behavior?

Being able to use ng-container inside mat-list-grid, so it would allow to have ngSwitch or *ngFor doing some logic before creating the item.

What is the current behavior?

If you try to add ng-container nothing is rendered.

What are the steps to reproduce?

1 - Create a mat-grid-list
2 - Add ng-container with ngFor or ngSwitch
3 - Add the mat-grid-tile, and nothing is rendered

https://stackblitz.com/edit/angular-material2-issue-8vvb8z

What is the use-case or motivation for changing an existing behavior?

Being able to generate a dashboard dynamically based on the type of component you need to load, and use breakpointObserver to define the number of columns based on the type of the widget.

For example:
widget 1 loads a map
widget 2 loads a random number of charts, where it chart should be a tile

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

Angular 6.1.2
Angular Material 6.4.5
macOS 10.13.6
Typescript 2.9.2
All Browsers

@geromegrignon
Copy link
Contributor

mat-grid-list is an host element, you shouldn't rely on ng-container for your structural directives and use them directly in mat-grid-list balise tag.

<mat-grid-list cols="6" rowHeight="350px" *ngFor="let card of cards" [ngSwitch]="card.type">

@tbnovaes
Copy link
Author

@geromegrignon Yes I understand, but I still think that limiting it to accept only mat-grid-tile as its child, does not allow too much flexibility on a more complex view. And while I could use flex-layout to achieve the responsive the design I need, it would not be as easy to maintain as using the grid.

@crisbeto crisbeto self-assigned this Aug 24, 2018
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent has pr labels Aug 24, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 24, 2018
Fixes tiles that aren't direct descendants of the grid list not being styled.

Fixes angular#12809.
jelbourn pushed a commit that referenced this issue Aug 25, 2018
Fixes tiles that aren't direct descendants of the grid list not being styled.

Fixes #12809.
jelbourn pushed a commit that referenced this issue Aug 27, 2018
Fixes tiles that aren't direct descendants of the grid list not being styled.

Fixes #12809.
jelbourn pushed a commit that referenced this issue Aug 29, 2018
Fixes tiles that aren't direct descendants of the grid list not being styled.

Fixes #12809.
@FirstVertex
Copy link

Please reopen this issue. It is not fixed in @angular/[email protected]

See my Stackblitz link here: https://stackblitz.com/edit/angular-material2-issue-zdxvqh

I try to use ng-container with ng-template because i want to transclude the content instead of having that as a string.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants