-
Notifications
You must be signed in to change notification settings - Fork 241
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
request for modal to be launched with a service that is given a component #104
Comments
Just so I understand better. Well this is problematic in many ways and will not work with offline compilation. Anyway, it's not the responsibility of the modal library. The responsibility of the modal library is to present components, what you want is a something that should be done in a different library and output a It's important to keep things simple and separated, a modal library is not a Component factory.... |
Well, up to you, of course. Here is a proof of concept. https://plnkr.co/edit/Cua6HJYrN3i2SkgC0iLj?p=preview It think something like this is necessary in order to follow the style guide's (https://angular.io/docs/ts/latest/guide/style-guide.html) requirement of "single responsibility". Otherwise, how do you isolate the modal's implementation from the caller's implementation? How do you call the same modal from multiple locations? |
@kokokenada I don't understand how this differs from the current implementation. In the current implementation you provide a Component type, which is the same as the example above just with a Type rather then a string literal that is the selector. This means that the current approach is Type safe, less errors. The single responsibility principle holds, modal service only show a modal, the UI part of the modal dialog is managed by the component, which can be custom or a user can use a built in one... Current me if i'm wrong, the only difference is that current approach requires you to import the component's class, your approach does not require it but since it uses a string literal it not type safe. |
@shlomiassaf - thanks for the reply. Sounds like I misunderstand your API. Can you provide an example? (A button in Component A, should launch a modal defined in Component B) |
I'm working on something I think is similar.
Clicking on the button will open the dialog with the ChildComponent within. |
I'd like to define the modal content as a Component and launch it like:
where this.modalService is created through DI, parameter 1 matches the selector attribute of the Component and parameter 2 provides the component with all of the @input s that it requires.
The implementation of the modal Component can call the same service to close and resolve.
This would allow the modal definitions to be localized to one file or directory.
The text was updated successfully, but these errors were encountered: