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

Dynamically Loaded Components(Dialog, Toast) #783

Closed
borislemke opened this issue Jun 29, 2016 · 7 comments
Closed

Dynamically Loaded Components(Dialog, Toast) #783

borislemke opened this issue Jun 29, 2016 · 7 comments

Comments

@borislemke
Copy link

Bug, feature request, or proposal:

I noticed that the Angular team hasn't started on components that needs to be dynamically loaded such as the MD Dialog and MD Toast present in Angular Material 1. There is no best practice in how to load and destroy elements like these in Angular 2. Any ideas on how this can be achieved?

In Angular Material 1, we could also pass data into the dialog and output data when the dialog is destroyed/hidden(promise based).

What is the expected behavior?

Dynamically load components into the view for modals, toasts and the likes

What is the current behavior?

No proper documentation

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

If the Angular team has started on at least one of these components(dialog or toast), we may start exploring the possibilities of how to best handle dynamically loaded components and create our own

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

Angular 2.0.0-rc.3
Angular Material 2.0.0-alpha.5-2

@TheCaptainDate
Copy link

TheCaptainDate commented Jun 29, 2016

We can pass any data to dynamic components by using of ng-content.

In case of Modal we actually can place our html things inside any component that gonna use this Modal because modal should not draw itself before call of popup() or something. Also modal should have absolute position and z-index so there is no any reason for modal to be pasted somewhere at the special place (like root component or etc).

You can just write your modal where you want, pass data by using of ng-content and finally draw it when *ngif becomes true.

From the other hand it will be cool if modal component can be written only ones somewhere in root component and then just been reused when need to.

@borislemke
Copy link
Author

borislemke commented Jun 30, 2016

Thanks for the reply @TheCaptainDate . However, in Angular Material 1.x, this is not how dialogs and toasts work. They just get injected by a service-like module($mdDialog) which does not require the explicit declaration of a selector element(e.g my-dialog) in the document. These element will just get dynamically injected into the documents body. I'm keen to know what the Angular team thinks and whether they can give a better insight.

@TheCaptainDate
Copy link

@borislemke take a look

@borislemke
Copy link
Author

@TheCaptainDate thanks mate! Exactly what I was looking for. Will keep track of it

@jelbourn
Copy link
Member

Check out #761.

More coming soon!

@m00zi
Copy link

m00zi commented Mar 2, 2017

ng-content solved my problem. Thanks

@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 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants