Reusable component is not working in angular











up vote
1
down vote

favorite












My project folder structure is like below



enter image description here



I trying to use reusable component in my module. For that I'm using products component inside login component but it showing like below




app-products' is not a known element:
1. If 'app-products' is an Angular component, then verify that it is part of this module.
2. If 'app-products' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("




And my home.module.ts is like below



imports: [
CommonModule,
RouterModule.forChild(HomeRoutingModule),
],
declarations: [UserProfileComponent,ProductsComponent],
exports:[ProductsComponent]
})


could any one please help in this regard how to solve this error










share|improve this question
























  • which Module the login component is declared in ?
    – Sunil Singh
    2 days ago










  • app.module.ts consisting
    – change need
    2 days ago















up vote
1
down vote

favorite












My project folder structure is like below



enter image description here



I trying to use reusable component in my module. For that I'm using products component inside login component but it showing like below




app-products' is not a known element:
1. If 'app-products' is an Angular component, then verify that it is part of this module.
2. If 'app-products' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("




And my home.module.ts is like below



imports: [
CommonModule,
RouterModule.forChild(HomeRoutingModule),
],
declarations: [UserProfileComponent,ProductsComponent],
exports:[ProductsComponent]
})


could any one please help in this regard how to solve this error










share|improve this question
























  • which Module the login component is declared in ?
    – Sunil Singh
    2 days ago










  • app.module.ts consisting
    – change need
    2 days ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











My project folder structure is like below



enter image description here



I trying to use reusable component in my module. For that I'm using products component inside login component but it showing like below




app-products' is not a known element:
1. If 'app-products' is an Angular component, then verify that it is part of this module.
2. If 'app-products' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("




And my home.module.ts is like below



imports: [
CommonModule,
RouterModule.forChild(HomeRoutingModule),
],
declarations: [UserProfileComponent,ProductsComponent],
exports:[ProductsComponent]
})


could any one please help in this regard how to solve this error










share|improve this question















My project folder structure is like below



enter image description here



I trying to use reusable component in my module. For that I'm using products component inside login component but it showing like below




app-products' is not a known element:
1. If 'app-products' is an Angular component, then verify that it is part of this module.
2. If 'app-products' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("




And my home.module.ts is like below



imports: [
CommonModule,
RouterModule.forChild(HomeRoutingModule),
],
declarations: [UserProfileComponent,ProductsComponent],
exports:[ProductsComponent]
})


could any one please help in this regard how to solve this error







angular typescript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked 2 days ago









change need

807




807












  • which Module the login component is declared in ?
    – Sunil Singh
    2 days ago










  • app.module.ts consisting
    – change need
    2 days ago


















  • which Module the login component is declared in ?
    – Sunil Singh
    2 days ago










  • app.module.ts consisting
    – change need
    2 days ago
















which Module the login component is declared in ?
– Sunil Singh
2 days ago




which Module the login component is declared in ?
– Sunil Singh
2 days ago












app.module.ts consisting
– change need
2 days ago




app.module.ts consisting
– change need
2 days ago












2 Answers
2






active

oldest

votes

















up vote
2
down vote














Either you import HomeModule in AppModule or you must declare the Login Component in HomeModule.




imports: [
HomeModule
],
declarations:
})
export class AppModule





share|improve this answer






























    up vote
    0
    down vote













    Home module seems to be a common module not a root module - so if you want to use components or directive from that module you need to export those components - you have done correctly



    Finally - angular will run on the root module you need to make sure that you are going to use this module in your application - so just import HomeModule in your AppModule



    imports: [
    HomeModule
    ],
    declarations:
    })
    export class AppModule


    This will stop lazy loading on HomeModule - to achieve lazy just bind components from common module by routing - hope this helps - Thanks happy coding !!






    share|improve this answer





















      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',
      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%2f53238588%2freusable-component-is-not-working-in-angular%23new-answer', 'question_page');
      }
      );

      Post as a guest
































      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote














      Either you import HomeModule in AppModule or you must declare the Login Component in HomeModule.




      imports: [
      HomeModule
      ],
      declarations:
      })
      export class AppModule





      share|improve this answer



























        up vote
        2
        down vote














        Either you import HomeModule in AppModule or you must declare the Login Component in HomeModule.




        imports: [
        HomeModule
        ],
        declarations:
        })
        export class AppModule





        share|improve this answer

























          up vote
          2
          down vote










          up vote
          2
          down vote










          Either you import HomeModule in AppModule or you must declare the Login Component in HomeModule.




          imports: [
          HomeModule
          ],
          declarations:
          })
          export class AppModule





          share|improve this answer















          Either you import HomeModule in AppModule or you must declare the Login Component in HomeModule.




          imports: [
          HomeModule
          ],
          declarations:
          })
          export class AppModule






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          Sunil Singh

          4,5941624




          4,5941624
























              up vote
              0
              down vote













              Home module seems to be a common module not a root module - so if you want to use components or directive from that module you need to export those components - you have done correctly



              Finally - angular will run on the root module you need to make sure that you are going to use this module in your application - so just import HomeModule in your AppModule



              imports: [
              HomeModule
              ],
              declarations:
              })
              export class AppModule


              This will stop lazy loading on HomeModule - to achieve lazy just bind components from common module by routing - hope this helps - Thanks happy coding !!






              share|improve this answer

























                up vote
                0
                down vote













                Home module seems to be a common module not a root module - so if you want to use components or directive from that module you need to export those components - you have done correctly



                Finally - angular will run on the root module you need to make sure that you are going to use this module in your application - so just import HomeModule in your AppModule



                imports: [
                HomeModule
                ],
                declarations:
                })
                export class AppModule


                This will stop lazy loading on HomeModule - to achieve lazy just bind components from common module by routing - hope this helps - Thanks happy coding !!






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Home module seems to be a common module not a root module - so if you want to use components or directive from that module you need to export those components - you have done correctly



                  Finally - angular will run on the root module you need to make sure that you are going to use this module in your application - so just import HomeModule in your AppModule



                  imports: [
                  HomeModule
                  ],
                  declarations:
                  })
                  export class AppModule


                  This will stop lazy loading on HomeModule - to achieve lazy just bind components from common module by routing - hope this helps - Thanks happy coding !!






                  share|improve this answer












                  Home module seems to be a common module not a root module - so if you want to use components or directive from that module you need to export those components - you have done correctly



                  Finally - angular will run on the root module you need to make sure that you are going to use this module in your application - so just import HomeModule in your AppModule



                  imports: [
                  HomeModule
                  ],
                  declarations:
                  })
                  export class AppModule


                  This will stop lazy loading on HomeModule - to achieve lazy just bind components from common module by routing - hope this helps - Thanks happy coding !!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 days ago









                  Rahul Swamynathan

                  62016




                  62016






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238588%2freusable-component-is-not-working-in-angular%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest




















































































                      Popular posts from this blog

                      Florida Star v. B. J. F.

                      Error while running script in elastic search , gateway timeout

                      Adding quotations to stringified JSON object values