Shared component not working when imported into lazy loading module












0















I am trying to load one shared component inside my lazy loaded module.
module. My lazy module imports the SharedModule like that:



// LazyModule



@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule.forChild(routes)
],
declarations: [
LazyParentComponent
]
})


Inside my SharedModule, I am importing the Angular material components that I need for the MenuComponent which I export as a shared component:



//SharedModule



@NgModule({
imports: [CommonModule],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})


Then in my LazyParentComponent I am using <app-menu></app-menu> which should render the MenuComponent, which I include in the sharedModule.



But if I start this, I always get a lot of errors like Can't bind to 'value' since it isn't a known property of 'mat-select'. or 'mat-toolbar' is not a known element.



It does however work, if I don't use <app-menu></app-menu> but instead use the MatButtons from the MatButtonModule directly.










share|improve this question























  • inside the shared module do you add the components to both declarations and exports?

    – omer
    Nov 14 '18 at 21:17













  • I didn't include them in the descriptions but I just saw, that some of the errors go away if I include them in the imports (It's also done like that in the app.module.ts)

    – Fabio ha
    Nov 14 '18 at 21:23











  • it doesn't sound right imports are for modules..

    – omer
    Nov 14 '18 at 21:25













  • Oh right yes, I see. The MenuComponent is in declarations and export. I was talking about the Angular Material modules

    – Fabio ha
    Nov 14 '18 at 21:27
















0















I am trying to load one shared component inside my lazy loaded module.
module. My lazy module imports the SharedModule like that:



// LazyModule



@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule.forChild(routes)
],
declarations: [
LazyParentComponent
]
})


Inside my SharedModule, I am importing the Angular material components that I need for the MenuComponent which I export as a shared component:



//SharedModule



@NgModule({
imports: [CommonModule],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})


Then in my LazyParentComponent I am using <app-menu></app-menu> which should render the MenuComponent, which I include in the sharedModule.



But if I start this, I always get a lot of errors like Can't bind to 'value' since it isn't a known property of 'mat-select'. or 'mat-toolbar' is not a known element.



It does however work, if I don't use <app-menu></app-menu> but instead use the MatButtons from the MatButtonModule directly.










share|improve this question























  • inside the shared module do you add the components to both declarations and exports?

    – omer
    Nov 14 '18 at 21:17













  • I didn't include them in the descriptions but I just saw, that some of the errors go away if I include them in the imports (It's also done like that in the app.module.ts)

    – Fabio ha
    Nov 14 '18 at 21:23











  • it doesn't sound right imports are for modules..

    – omer
    Nov 14 '18 at 21:25













  • Oh right yes, I see. The MenuComponent is in declarations and export. I was talking about the Angular Material modules

    – Fabio ha
    Nov 14 '18 at 21:27














0












0








0








I am trying to load one shared component inside my lazy loaded module.
module. My lazy module imports the SharedModule like that:



// LazyModule



@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule.forChild(routes)
],
declarations: [
LazyParentComponent
]
})


Inside my SharedModule, I am importing the Angular material components that I need for the MenuComponent which I export as a shared component:



//SharedModule



@NgModule({
imports: [CommonModule],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})


Then in my LazyParentComponent I am using <app-menu></app-menu> which should render the MenuComponent, which I include in the sharedModule.



But if I start this, I always get a lot of errors like Can't bind to 'value' since it isn't a known property of 'mat-select'. or 'mat-toolbar' is not a known element.



It does however work, if I don't use <app-menu></app-menu> but instead use the MatButtons from the MatButtonModule directly.










share|improve this question














I am trying to load one shared component inside my lazy loaded module.
module. My lazy module imports the SharedModule like that:



// LazyModule



@NgModule({
imports: [
CommonModule,
SharedModule,
RouterModule.forChild(routes)
],
declarations: [
LazyParentComponent
]
})


Inside my SharedModule, I am importing the Angular material components that I need for the MenuComponent which I export as a shared component:



//SharedModule



@NgModule({
imports: [CommonModule],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})


Then in my LazyParentComponent I am using <app-menu></app-menu> which should render the MenuComponent, which I include in the sharedModule.



But if I start this, I always get a lot of errors like Can't bind to 'value' since it isn't a known property of 'mat-select'. or 'mat-toolbar' is not a known element.



It does however work, if I don't use <app-menu></app-menu> but instead use the MatButtons from the MatButtonModule directly.







angular lazy-loading angular-module






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 21:03









Fabio haFabio ha

178215




178215













  • inside the shared module do you add the components to both declarations and exports?

    – omer
    Nov 14 '18 at 21:17













  • I didn't include them in the descriptions but I just saw, that some of the errors go away if I include them in the imports (It's also done like that in the app.module.ts)

    – Fabio ha
    Nov 14 '18 at 21:23











  • it doesn't sound right imports are for modules..

    – omer
    Nov 14 '18 at 21:25













  • Oh right yes, I see. The MenuComponent is in declarations and export. I was talking about the Angular Material modules

    – Fabio ha
    Nov 14 '18 at 21:27



















  • inside the shared module do you add the components to both declarations and exports?

    – omer
    Nov 14 '18 at 21:17













  • I didn't include them in the descriptions but I just saw, that some of the errors go away if I include them in the imports (It's also done like that in the app.module.ts)

    – Fabio ha
    Nov 14 '18 at 21:23











  • it doesn't sound right imports are for modules..

    – omer
    Nov 14 '18 at 21:25













  • Oh right yes, I see. The MenuComponent is in declarations and export. I was talking about the Angular Material modules

    – Fabio ha
    Nov 14 '18 at 21:27

















inside the shared module do you add the components to both declarations and exports?

– omer
Nov 14 '18 at 21:17







inside the shared module do you add the components to both declarations and exports?

– omer
Nov 14 '18 at 21:17















I didn't include them in the descriptions but I just saw, that some of the errors go away if I include them in the imports (It's also done like that in the app.module.ts)

– Fabio ha
Nov 14 '18 at 21:23





I didn't include them in the descriptions but I just saw, that some of the errors go away if I include them in the imports (It's also done like that in the app.module.ts)

– Fabio ha
Nov 14 '18 at 21:23













it doesn't sound right imports are for modules..

– omer
Nov 14 '18 at 21:25







it doesn't sound right imports are for modules..

– omer
Nov 14 '18 at 21:25















Oh right yes, I see. The MenuComponent is in declarations and export. I was talking about the Angular Material modules

– Fabio ha
Nov 14 '18 at 21:27





Oh right yes, I see. The MenuComponent is in declarations and export. I was talking about the Angular Material modules

– Fabio ha
Nov 14 '18 at 21:27












1 Answer
1






active

oldest

votes


















1














You need to include all material modules in imports as well:



Shared Module



@NgModule({
imports: [CommonModule,
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule
],
declarations: [MenuComponent],
exports: [
MatButtonModule,
MatSelectModule,
MatInputModule,
MatOptionModule,
MatToolbarModule,
MenuComponent
]
})





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',
    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%2f53308677%2fshared-component-not-working-when-imported-into-lazy-loading-module%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You need to include all material modules in imports as well:



    Shared Module



    @NgModule({
    imports: [CommonModule,
    MatButtonModule,
    MatSelectModule,
    MatInputModule,
    MatOptionModule,
    MatToolbarModule
    ],
    declarations: [MenuComponent],
    exports: [
    MatButtonModule,
    MatSelectModule,
    MatInputModule,
    MatOptionModule,
    MatToolbarModule,
    MenuComponent
    ]
    })





    share|improve this answer




























      1














      You need to include all material modules in imports as well:



      Shared Module



      @NgModule({
      imports: [CommonModule,
      MatButtonModule,
      MatSelectModule,
      MatInputModule,
      MatOptionModule,
      MatToolbarModule
      ],
      declarations: [MenuComponent],
      exports: [
      MatButtonModule,
      MatSelectModule,
      MatInputModule,
      MatOptionModule,
      MatToolbarModule,
      MenuComponent
      ]
      })





      share|improve this answer


























        1












        1








        1







        You need to include all material modules in imports as well:



        Shared Module



        @NgModule({
        imports: [CommonModule,
        MatButtonModule,
        MatSelectModule,
        MatInputModule,
        MatOptionModule,
        MatToolbarModule
        ],
        declarations: [MenuComponent],
        exports: [
        MatButtonModule,
        MatSelectModule,
        MatInputModule,
        MatOptionModule,
        MatToolbarModule,
        MenuComponent
        ]
        })





        share|improve this answer













        You need to include all material modules in imports as well:



        Shared Module



        @NgModule({
        imports: [CommonModule,
        MatButtonModule,
        MatSelectModule,
        MatInputModule,
        MatOptionModule,
        MatToolbarModule
        ],
        declarations: [MenuComponent],
        exports: [
        MatButtonModule,
        MatSelectModule,
        MatInputModule,
        MatOptionModule,
        MatToolbarModule,
        MenuComponent
        ]
        })






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 2:11









        User3250User3250

        1,6253928




        1,6253928
































            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%2f53308677%2fshared-component-not-working-when-imported-into-lazy-loading-module%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

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python