maximelafarie / ngx-smart-modal

Modal/Dialog component crafted for Angular (Ivy-compatible)
https://maximelafarie.com/ngx-smart-modal/
MIT License
325 stars 85 forks source link

modalService create<>() throws NG0902: This view is already attached to a ViewContainer! #379

Closed ArneSchoonvliet closed 10 months ago

ArneSchoonvliet commented 1 year ago

Given example code:

import { Component, ViewContainerRef } from '@angular/core';
import { NgxSmartModalService } from 'ngx-smart-modal';

@Component({
  selector: 'my-app',
  template: '<div>test</div>',
})
export class AppComponent {
  constructor(
    private vcr: ViewContainerRef,
    private modalService: NgxSmartModalService
  ) {
    this.modalService.create(this.vcr, 'mymodal', 'my awesome content').open();
  }
}

Throws the error NG0902: This view is already attached to a ViewContainer!

Version: 14.0.2 Angular: 16.1

trav164 commented 1 year ago

Any updates on this issue?

milson44 commented 1 year ago

I'm waiting too

jamielegg commented 1 year ago

Similar boat too, would be good to have this fixed.

maximelafarie commented 1 year ago

I'm trying to fix that. The library used to use ComponentFactoryResolver, which has since been deprecated. So I'm looking at how to restore this default behavior with viewContainerRef.createComponent() which seems to be the new way of doing things. If you can (or want to) help me, you're very welcome. (It's been a long time since I've looked at Angular again, and versions have changed a lot since then)

Idk if @khylias or @LouisAugry can help me solving this 😇.

ArneSchoonvliet commented 1 year ago

@maximelafarie Thanks for the update and informing us that you are working on it. I'm more then happy to have a look myself for a fix. I'm just wondering if the latest code is available on master, the function signature provided in the released package doesn't match the function signature available on the master branch https://github.com/maximelafarie/ngx-smart-modal/blob/ada1ca533c5e1928667db76a7e3f2de8a02ede16/projects/ngx-smart-modal/src/lib/services/ngx-smart-modal.service.ts#L222C114-L222C114

or am I missing something?

PetroSuch commented 1 year ago

Hi everyone! Does anyone have any updates/fixes regarding this bug? Thanks!

ArneSchoonvliet commented 11 months ago

@maximelafarie I don't want too pressure you at all but it's a blocker for us the upgrade to the next Angular version. I'm more then happy to provide a fix but I just need confirmation that the code on the master branch is the actual code currently being distributed. If not, where can I find it? Reason I ask is because the exposed public api is different compared to the code available on the master branch.

Thanks for providing this package and I'm looking forward to your response! Kind regards Arne

milson44 commented 11 months ago

I agree with @ArneSchoonvliet, it's a blocker for us too, we wanna try out signals in Angular 16. I've been checking this issue every week since august, but nothing has changed

maximelafarie commented 11 months ago

Sorry for the delay, folks, but I've got some personal commitments that mean I can't move as fast as I'd like on all your feedback. I can confirm that the code on master is up to date. Thanks a million for your help @ArneSchoonvliet. As soon as your PR is ready, I'll merge and release it.

AliKholmatov commented 10 months ago

Hi. Any updates ?)