0

I have an Angular application, it is an simple application with routing. I have to include my application as a part of another website, the website load the app into a modal after loading all dependencies via RequireJS.

The opening of the app into a modal works fine.

When the modal is dismissed (and node us dismissed with the modal) I suppose the app is destroyed.

But after modal dismiss the app seems still in memory and if I open the modal again I didn't see the application loaded (and neither catch any error).

After first usage I obtain a blank page.

So I guess that I have to force app destroy on modal dismission.

Any suggestions?

=== UPDATE ===

I tryed to follow two different ways.

  1. using RequireJS undefine

    I receive an error message and it doesn't seems works

  2. include main.js via Ajax request

    I didn't receive any errors but it doesn't seems works

In any case I see that Angular app seems still works, I can read the messages in console log sent by Angular controllers but the render doesn't works.

When include the main.js for the second time I read all console log message except the message in main constructor.

Zauker
  • 2,344
  • 3
  • 27
  • 36
  • I believe your question requires investigation and debugging of what really happends. The thing that I think will work in most of the cases is [angular elements](https://angular.io/guide/elements). I believe that if you make your angular app an angular element it will be working fine – Andrei Sep 25 '20 at 16:35
  • Why are you using requirejs with angular? Do you mean angularjs? – mwilson Sep 25 '20 at 16:39
  • @Andrei after some test it seems the app still working, I can see the log to some ajax call and so on, but the render on page missing. The tag is append on the modal when it was opened and removed when the modal was dismissed. – Zauker Sep 28 '20 at 08:17
  • @mwilson is a requirement of the site that include the app. – Zauker Sep 28 '20 at 08:18
  • I still think that angular elements is the best option for you – Andrei Sep 28 '20 at 08:56
  • RequireJS has method to undefine module, maybe it will be useful https://requirejs.org/docs/api.html#undef – Damian Dziaduch Sep 28 '20 at 12:12
  • @Zauker You should fight that one. RequireJS has no place in angular. It has it's own bundling system that is far superior than requirejs. – mwilson Sep 28 '20 at 15:31
  • @DamianDziaduch I tried but I receive a Error Message. I tried also to include main.js as ajax call, but It still doesn't work. Or better as I wrote in my update, the app seems work, I see that it perform Ajax call etc. But the render of the view is missing. – Zauker Sep 29 '20 at 10:09
  • @mwilson I know, but the site offer only this kind of inclusion, before we included a similar app via iframe, but now we can't use it. – Zauker Sep 29 '20 at 10:11

0 Answers0