Ionic 3 Lazy Loading Definitive Reference












0















I'm working on an Ionic app. It's based on code I wrote last year using Ionic 2. I've since upgraded my laptop and gone through the usual process of installing all my goodies again, including making the leap to the most recent versions of Ionic 3 and Cordova. I've mutilated my app, testing it as I go using $ ionic serve -c and devApp. All seemed to be working fine until I got o actually build it for Android. It then turns out that there is a whole array of problems, from what I can see associated with lazy loading.



Basically, my starting code (Ionic 2) had lots of :



  import { DeviceviewPage } from '../pages/deviceview/deviceview';


declarations: [
DeviceviewPage,
...


entryComponents: [
DeviceviewPage,


type page declarations in app.module.ts. However, each page I auto-generated with Ionic created a pageModule.ts; page.ts pair geared towards lazy loading. So, stuck in between methodologies, I went off and google lazy loading to get everything into that format. Whereupon, the only thing that became clear was that Ionic Lazy Loading is not clear in most contributor's minds. Of the hundreds of forum Q&As, there is a definite spread of opinions as to how this should work.



Some insist that you should reference your individual modules in your app.module.ts.



import { DeviceviewPageModule } from '../pages/deviceview/deviceview.module';


and remove all references to the DeviceviewPage.ts.



I did this for a few pages and it seemed to hang together. But the wheels fell off when I got to a page which had another lazy loaded component within it. when I tried the approach above, I got he following error:



    Can't bind to 'data' since it isn't a known property of 'myComponent'.
1. If 'myComponent' is an Angular component and it has 'data' input, then verify that it is part of this module.
2. If 'myComponent' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("


Upon looking into lazy Loading a bit more, it seems there's a bit more required than indicated by the above, and that the forum advise was just flat out wrong.



The following excellent resource:



https://github.com/learn-ionic/ionic3-lazy-loading-example



looks like it could be trustworthy. But as it would involve quite a substantial hack to bring my code into line with the methods used, I thought it might be prudent to call upon the might of the Stack to give it the seal of approval before I waste a heap of time (only to find that someone else has a better way of doing it, that I should learn!)



I hope this question, and moreso the answers are useful to others making the transition from Ionic 2 -> ionic 3, particularly those like me who know have next to no coding skill.










share|improve this question



























    0















    I'm working on an Ionic app. It's based on code I wrote last year using Ionic 2. I've since upgraded my laptop and gone through the usual process of installing all my goodies again, including making the leap to the most recent versions of Ionic 3 and Cordova. I've mutilated my app, testing it as I go using $ ionic serve -c and devApp. All seemed to be working fine until I got o actually build it for Android. It then turns out that there is a whole array of problems, from what I can see associated with lazy loading.



    Basically, my starting code (Ionic 2) had lots of :



      import { DeviceviewPage } from '../pages/deviceview/deviceview';


    declarations: [
    DeviceviewPage,
    ...


    entryComponents: [
    DeviceviewPage,


    type page declarations in app.module.ts. However, each page I auto-generated with Ionic created a pageModule.ts; page.ts pair geared towards lazy loading. So, stuck in between methodologies, I went off and google lazy loading to get everything into that format. Whereupon, the only thing that became clear was that Ionic Lazy Loading is not clear in most contributor's minds. Of the hundreds of forum Q&As, there is a definite spread of opinions as to how this should work.



    Some insist that you should reference your individual modules in your app.module.ts.



    import { DeviceviewPageModule } from '../pages/deviceview/deviceview.module';


    and remove all references to the DeviceviewPage.ts.



    I did this for a few pages and it seemed to hang together. But the wheels fell off when I got to a page which had another lazy loaded component within it. when I tried the approach above, I got he following error:



        Can't bind to 'data' since it isn't a known property of 'myComponent'.
    1. If 'myComponent' is an Angular component and it has 'data' input, then verify that it is part of this module.
    2. If 'myComponent' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("


    Upon looking into lazy Loading a bit more, it seems there's a bit more required than indicated by the above, and that the forum advise was just flat out wrong.



    The following excellent resource:



    https://github.com/learn-ionic/ionic3-lazy-loading-example



    looks like it could be trustworthy. But as it would involve quite a substantial hack to bring my code into line with the methods used, I thought it might be prudent to call upon the might of the Stack to give it the seal of approval before I waste a heap of time (only to find that someone else has a better way of doing it, that I should learn!)



    I hope this question, and moreso the answers are useful to others making the transition from Ionic 2 -> ionic 3, particularly those like me who know have next to no coding skill.










    share|improve this question

























      0












      0








      0








      I'm working on an Ionic app. It's based on code I wrote last year using Ionic 2. I've since upgraded my laptop and gone through the usual process of installing all my goodies again, including making the leap to the most recent versions of Ionic 3 and Cordova. I've mutilated my app, testing it as I go using $ ionic serve -c and devApp. All seemed to be working fine until I got o actually build it for Android. It then turns out that there is a whole array of problems, from what I can see associated with lazy loading.



      Basically, my starting code (Ionic 2) had lots of :



        import { DeviceviewPage } from '../pages/deviceview/deviceview';


      declarations: [
      DeviceviewPage,
      ...


      entryComponents: [
      DeviceviewPage,


      type page declarations in app.module.ts. However, each page I auto-generated with Ionic created a pageModule.ts; page.ts pair geared towards lazy loading. So, stuck in between methodologies, I went off and google lazy loading to get everything into that format. Whereupon, the only thing that became clear was that Ionic Lazy Loading is not clear in most contributor's minds. Of the hundreds of forum Q&As, there is a definite spread of opinions as to how this should work.



      Some insist that you should reference your individual modules in your app.module.ts.



      import { DeviceviewPageModule } from '../pages/deviceview/deviceview.module';


      and remove all references to the DeviceviewPage.ts.



      I did this for a few pages and it seemed to hang together. But the wheels fell off when I got to a page which had another lazy loaded component within it. when I tried the approach above, I got he following error:



          Can't bind to 'data' since it isn't a known property of 'myComponent'.
      1. If 'myComponent' is an Angular component and it has 'data' input, then verify that it is part of this module.
      2. If 'myComponent' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
      3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("


      Upon looking into lazy Loading a bit more, it seems there's a bit more required than indicated by the above, and that the forum advise was just flat out wrong.



      The following excellent resource:



      https://github.com/learn-ionic/ionic3-lazy-loading-example



      looks like it could be trustworthy. But as it would involve quite a substantial hack to bring my code into line with the methods used, I thought it might be prudent to call upon the might of the Stack to give it the seal of approval before I waste a heap of time (only to find that someone else has a better way of doing it, that I should learn!)



      I hope this question, and moreso the answers are useful to others making the transition from Ionic 2 -> ionic 3, particularly those like me who know have next to no coding skill.










      share|improve this question














      I'm working on an Ionic app. It's based on code I wrote last year using Ionic 2. I've since upgraded my laptop and gone through the usual process of installing all my goodies again, including making the leap to the most recent versions of Ionic 3 and Cordova. I've mutilated my app, testing it as I go using $ ionic serve -c and devApp. All seemed to be working fine until I got o actually build it for Android. It then turns out that there is a whole array of problems, from what I can see associated with lazy loading.



      Basically, my starting code (Ionic 2) had lots of :



        import { DeviceviewPage } from '../pages/deviceview/deviceview';


      declarations: [
      DeviceviewPage,
      ...


      entryComponents: [
      DeviceviewPage,


      type page declarations in app.module.ts. However, each page I auto-generated with Ionic created a pageModule.ts; page.ts pair geared towards lazy loading. So, stuck in between methodologies, I went off and google lazy loading to get everything into that format. Whereupon, the only thing that became clear was that Ionic Lazy Loading is not clear in most contributor's minds. Of the hundreds of forum Q&As, there is a definite spread of opinions as to how this should work.



      Some insist that you should reference your individual modules in your app.module.ts.



      import { DeviceviewPageModule } from '../pages/deviceview/deviceview.module';


      and remove all references to the DeviceviewPage.ts.



      I did this for a few pages and it seemed to hang together. But the wheels fell off when I got to a page which had another lazy loaded component within it. when I tried the approach above, I got he following error:



          Can't bind to 'data' since it isn't a known property of 'myComponent'.
      1. If 'myComponent' is an Angular component and it has 'data' input, then verify that it is part of this module.
      2. If 'myComponent' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
      3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("


      Upon looking into lazy Loading a bit more, it seems there's a bit more required than indicated by the above, and that the forum advise was just flat out wrong.



      The following excellent resource:



      https://github.com/learn-ionic/ionic3-lazy-loading-example



      looks like it could be trustworthy. But as it would involve quite a substantial hack to bring my code into line with the methods used, I thought it might be prudent to call upon the might of the Stack to give it the seal of approval before I waste a heap of time (only to find that someone else has a better way of doing it, that I should learn!)



      I hope this question, and moreso the answers are useful to others making the transition from Ionic 2 -> ionic 3, particularly those like me who know have next to no coding skill.







      ionic-framework ionic3 lazy-loading






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 23:05









      monkeymonkey

      83




      83
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271391%2fionic-3-lazy-loading-definitive-reference%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271391%2fionic-3-lazy-loading-definitive-reference%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          さくらももこ

          13 indicted, 8 arrested in Calif. drug cartel investigation