-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support @Output() : EventEmitter in NzDrawerService #3283
Comments
@ameckl You can use https://stackblitz.com/edit/angular-cgaitc?embed=1&file=src/app/app.component.ts |
Thank you for response. I'll refactor my code. It just seemed more right and idiomatic to use |
Maybe we can add component instance as a property of drawerRef
|
If everyone else was in my position triying to use this in a DrawerService and didn't make it work, you can solve it by using "componentInstance" property. public signDocument(documentId: string) {
const drawerRef = this.modalService.create({
nzTitle: undefined,
nzCloseIcon: 'close',
nzContent: SignOptionsComponent,
nzWidth: '60%',
nzFooter: null,
nzOkType: undefined,
nzComponentParams: {
documentId: documentId,
},
});
drawerRef.componentInstance?.onSignEvent.subscribe((event: any) => {
if (event == true) {
drawerRef.close();
}
});
} in my case "onSignEvent" is an output declared as a EventEmiiter in my component |
What problem does this feature solve?
The current implementation of NzDrawerService allows to pass @input() parameters for the component using NzContentParams, but does not allow to pass functions acting as callbacks when the component emits an event.
One can argue that the afterClose method can be used as an emitter, which I'm currently using. My only problem with this, in order to close the drawer from inside, I need to inject 'NzDrawerRef' into the component, but I don't always render that component using a drawer.
If NzDrawerService would support @output() parameters, one could create a drawer with a component that has zero reference to the drawerRef.
This is how I'm using it now:
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: