Coder Social home page Coder Social logo

Comments (6)

krigame avatar krigame commented on September 17, 2024 1

I created a blitz project, so it would be easier to reproduce the issue.
https://stackblitz.com/edit/angular-jmswek

You should download the project and run it locally, as the component build has to happen locally anyway. When serving the project with webpack the modal works and the confirm/decline messages are added to console log according to the button pressed on modal, so all is as expected.

Exporting a web component.

  • Comment out line 25: 'AppComponent' before build (otherwise the exported component still looks for the root tag)
  • UnComment lines 37-38 (blitz didn't like those lines for some reason, but these lines define the exported component)
  • Run 'npm run build:elements'
  • In the generated index.html, replace < my-app > with < page-views > as this is the exported web component
  • Open the index.html somewhere (I usually test them using WAMP, but there are probably some easier methods)
  • No modal should pop up after button press / related error should show up in console.

from ngx-simple-modal.

kevcjones-archived avatar kevcjones-archived commented on September 17, 2024

from ngx-simple-modal.

dima11221122 avatar dima11221122 commented on September 17, 2024

I have the same problem

from ngx-simple-modal.

kevcjones-archived avatar kevcjones-archived commented on September 17, 2024
PageComponent.html:2 ERROR TypeError: Cannot read property 'hostView' of undefined
    at SimpleModalService.get [as container] (simple-modal.service.js:58)
    at SimpleModalService.push../node_modules/ngx-simple-modal/dist/simple-modal/simple-modal.service.js.SimpleModalService.createSimpleModalHolder (simple-modal.service.js:77)
    at SimpleModalService.push../node_modules/ngx-simple-modal/dist/simple-modal/simple-modal.service.js.SimpleModalService.addModal (simple-modal.service.js:35)
    at PageComponent.push../src/app/page.component.ts.PageComponent.openModal (page.component.ts:22)
    at Object.eval [as handleEvent] (PageComponent.html:2)
    at handleEvent (core.js:21673)
    at callWithDebugContext (core.js:22767)
    at Object.debugHandleEvent [as handleEvent] (core.js:22470)
    at dispatchEvent (core.js:19122)
    at core.js:19569

from ngx-simple-modal.

kevcjones-archived avatar kevcjones-archived commented on September 17, 2024

Can replicate - still a bug. Will look into

from ngx-simple-modal.

kevcjones-archived avatar kevcjones-archived commented on September 17, 2024

Ok this wasn't technically a bug there were two things i did after i downloaded your project @krigame (btw i appreciate this is about 7 months late but this is for future people too).

  1. install "@webcomponents/webcomponentsjs": "^2.2.10", and add import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'; to the polyfills.

Then the main part - when you exported the web-component you defined a container `modal-container.

Basically that was needed

<html>
  <head>
    <title>Angular App</title>
  </head>
  <body>
    <page-views></page-views>
    <div id="modal-container"></div>
  <script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body>
</html>

I admit after seeing how ungracefully it handles misconfiguration i'm going to put in something that doesn't crap out in the next block which isn't friendly to webcomponents and have it default back to 'body' instead.

from ngx-simple-modal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.