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

NgbOffcanvasRef and NgbModalRef should expose a ComponentRef #4688

Open
pkfms opened this issue Mar 28, 2024 · 2 comments
Open

NgbOffcanvasRef and NgbModalRef should expose a ComponentRef #4688

pkfms opened this issue Mar 28, 2024 · 2 comments

Comments

@pkfms
Copy link

pkfms commented Mar 28, 2024

Bug description:

NgbOffcanvasRef and NgbModalRef should expose a ComponentRef when using a component type as content.
Currently the NgbOffcanvasRef exposes a componentInstance. This makes it hard to use components with Signal inputs, as you cannot do myComponentInstance.myProp = value. Instead, the proper way is to use the function setInput on a componentRef. setInput also triggers change detection and ngOnChanges correctly.

Link to minimally-working StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-5zsark-l3yj9i

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 17.3.1

ng-bootstrap: 16.0.0

Bootstrap: 5.3.3

@jnizet
Copy link
Member

jnizet commented Mar 28, 2024

I agree that it's not clean setting inputs programmatically on the modal component. OTOH, I've always wondered why the examples in the documentation decorate the properties set by the opening component with @Input(). They're not inputs and have no reason to be.

I generally expose an initialize() method in the modal component that the opening component calls once the component has been created by the modal service.

In your stackblitz, you could replace the inputs by regular writable signals.

@pkfms
Copy link
Author

pkfms commented Mar 28, 2024

Sure, that works in this example. I'm trying to share the content components and do things like opening a popover on desktop and offcanvas on mobile. or modal/offcanvas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants