-1

Tried to load an angular web app inside an ionic app using iframe, Main concern is, I need to use the locally stored values from ionic app to angular web app when entered through iframe instead of using query params which sometimes gave error as Error : URI too long

Ionic App -- http://localhost:8100/ng-iframe-loader

HTML code

 <iframe id="myiframe" allow="camera *;microphone *"  src=" localhost:4200" style="height: 100%;  width: 100%"> </iframe>

Ts Code

 const data = { message: 'Data Received' }
    const iframe: any = window.document.createElement('myiframe');

    iframe.onload = () => {
      debugger
      iframe.contentWindow.postMessage(data, '*');
    };
    document.body.appendChild(iframe);

Angular Web App rendered through Iframe-- http://localhost:4200/credit-mobile-form

App.component.ts code

window.addEventListener('message', (event: MessageEvent) => {
      if (event) {
        console.log(event.data, 'Received Data ===>>>');
      }
    });

Response received for event.data is undefined in angular web app

data : { data: undefined type: "webpackInvalid" (sometimes webpackOK) }
  • You already asked about this, an hour ago - https://stackoverflow.com/q/76866564/1427878 So why does this require a new question, under a new account, now ...? – CBroe Aug 09 '23 at 11:48
  • @Cbore need solution for this issue. previously the code was not clear, hope here the issue is clearly mentioned. – Murugan R Aug 09 '23 at 13:03
  • @MuruganR You are aware of the `Edit` option, right? – Dimitar Aug 09 '23 at 14:12
  • You have an iframe in your html but you’re also creating one..? – MikeOne Aug 09 '23 at 16:04

0 Answers0