Angular Library Modules export components, services and others from module





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I have created an Angular Library. In my Library I would it like it to be clean by having feature modules inside them:



Example:



Library
NavigationModule
NavigationSideBarComponent
NavigationTopComponent
Navigation Service
etc

GraphModule
BarGraphComponent
PieGraphComponent


My Navigation Module currently looks like this:



@NgModule({
declarations: [
NavigationSidebarComponent
],
imports: [
CommonModule,
MatSidenavModule
],
exports: [
NavigationSidebarComponent
]
})
export class NavigationModule { }


My Library Module currently looks like this:



@NgModule({
declarations: [LibraryComponent],
imports: [
NavigationModule
],
exports: [
LibraryComponent
//NavigationSidebarComponent <-- Did not work
]
})
export class LibraryModule { }


Most tutorials I am finding is using a library with only components in them and nothing else such as modules. The tutorials I do find using modules in a library do not show how to export pieces.



Essentially I want to import this Library into any application and be able to call NavigationSidebarComponent or any other component from a module in the library or service.



I will keep looking into this on my end.










share|improve this question

























  • I have never built and published a library, but I've noticed that some UI vendors publish individual modules to npm separately. Here's an example of a 3rd party vendor's Dropdown components module. npmjs.com/package/@progress/kendo-angular-dropdowns

    – Keenan Diggs
    Jan 2 at 21:21













  • Thanks Keenan, ya I am thinking maybe this is not possible. Only the ones that import the module have access to their components, etc. I was hoping to do it like this because then I could have one library with each module being a feature

    – L1ghtk3ira
    Jan 2 at 21:24











  • It is starting to look like I need to make a library for each which would be terrible to manage. Or put all components regardless of types like header, footer, tables, all in the library module.

    – L1ghtk3ira
    Jan 2 at 21:24











  • My main thought though is Angular supports it so I would assume it is dooable

    – L1ghtk3ira
    Jan 2 at 21:25











  • If you have a dependency of one module on another (using the BarGraphComponent in your NavigationTopComponent implementation for example), that might be okay. As long as the dependency is 1-way.

    – Keenan Diggs
    Jan 2 at 21:26




















1















I have created an Angular Library. In my Library I would it like it to be clean by having feature modules inside them:



Example:



Library
NavigationModule
NavigationSideBarComponent
NavigationTopComponent
Navigation Service
etc

GraphModule
BarGraphComponent
PieGraphComponent


My Navigation Module currently looks like this:



@NgModule({
declarations: [
NavigationSidebarComponent
],
imports: [
CommonModule,
MatSidenavModule
],
exports: [
NavigationSidebarComponent
]
})
export class NavigationModule { }


My Library Module currently looks like this:



@NgModule({
declarations: [LibraryComponent],
imports: [
NavigationModule
],
exports: [
LibraryComponent
//NavigationSidebarComponent <-- Did not work
]
})
export class LibraryModule { }


Most tutorials I am finding is using a library with only components in them and nothing else such as modules. The tutorials I do find using modules in a library do not show how to export pieces.



Essentially I want to import this Library into any application and be able to call NavigationSidebarComponent or any other component from a module in the library or service.



I will keep looking into this on my end.










share|improve this question

























  • I have never built and published a library, but I've noticed that some UI vendors publish individual modules to npm separately. Here's an example of a 3rd party vendor's Dropdown components module. npmjs.com/package/@progress/kendo-angular-dropdowns

    – Keenan Diggs
    Jan 2 at 21:21













  • Thanks Keenan, ya I am thinking maybe this is not possible. Only the ones that import the module have access to their components, etc. I was hoping to do it like this because then I could have one library with each module being a feature

    – L1ghtk3ira
    Jan 2 at 21:24











  • It is starting to look like I need to make a library for each which would be terrible to manage. Or put all components regardless of types like header, footer, tables, all in the library module.

    – L1ghtk3ira
    Jan 2 at 21:24











  • My main thought though is Angular supports it so I would assume it is dooable

    – L1ghtk3ira
    Jan 2 at 21:25











  • If you have a dependency of one module on another (using the BarGraphComponent in your NavigationTopComponent implementation for example), that might be okay. As long as the dependency is 1-way.

    – Keenan Diggs
    Jan 2 at 21:26
















1












1








1


1






I have created an Angular Library. In my Library I would it like it to be clean by having feature modules inside them:



Example:



Library
NavigationModule
NavigationSideBarComponent
NavigationTopComponent
Navigation Service
etc

GraphModule
BarGraphComponent
PieGraphComponent


My Navigation Module currently looks like this:



@NgModule({
declarations: [
NavigationSidebarComponent
],
imports: [
CommonModule,
MatSidenavModule
],
exports: [
NavigationSidebarComponent
]
})
export class NavigationModule { }


My Library Module currently looks like this:



@NgModule({
declarations: [LibraryComponent],
imports: [
NavigationModule
],
exports: [
LibraryComponent
//NavigationSidebarComponent <-- Did not work
]
})
export class LibraryModule { }


Most tutorials I am finding is using a library with only components in them and nothing else such as modules. The tutorials I do find using modules in a library do not show how to export pieces.



Essentially I want to import this Library into any application and be able to call NavigationSidebarComponent or any other component from a module in the library or service.



I will keep looking into this on my end.










share|improve this question
















I have created an Angular Library. In my Library I would it like it to be clean by having feature modules inside them:



Example:



Library
NavigationModule
NavigationSideBarComponent
NavigationTopComponent
Navigation Service
etc

GraphModule
BarGraphComponent
PieGraphComponent


My Navigation Module currently looks like this:



@NgModule({
declarations: [
NavigationSidebarComponent
],
imports: [
CommonModule,
MatSidenavModule
],
exports: [
NavigationSidebarComponent
]
})
export class NavigationModule { }


My Library Module currently looks like this:



@NgModule({
declarations: [LibraryComponent],
imports: [
NavigationModule
],
exports: [
LibraryComponent
//NavigationSidebarComponent <-- Did not work
]
})
export class LibraryModule { }


Most tutorials I am finding is using a library with only components in them and nothing else such as modules. The tutorials I do find using modules in a library do not show how to export pieces.



Essentially I want to import this Library into any application and be able to call NavigationSidebarComponent or any other component from a module in the library or service.



I will keep looking into this on my end.







angular import export angular-module angular-library






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 11:22









halfer

14.7k759116




14.7k759116










asked Jan 2 at 20:33









L1ghtk3iraL1ghtk3ira

77121134




77121134













  • I have never built and published a library, but I've noticed that some UI vendors publish individual modules to npm separately. Here's an example of a 3rd party vendor's Dropdown components module. npmjs.com/package/@progress/kendo-angular-dropdowns

    – Keenan Diggs
    Jan 2 at 21:21













  • Thanks Keenan, ya I am thinking maybe this is not possible. Only the ones that import the module have access to their components, etc. I was hoping to do it like this because then I could have one library with each module being a feature

    – L1ghtk3ira
    Jan 2 at 21:24











  • It is starting to look like I need to make a library for each which would be terrible to manage. Or put all components regardless of types like header, footer, tables, all in the library module.

    – L1ghtk3ira
    Jan 2 at 21:24











  • My main thought though is Angular supports it so I would assume it is dooable

    – L1ghtk3ira
    Jan 2 at 21:25











  • If you have a dependency of one module on another (using the BarGraphComponent in your NavigationTopComponent implementation for example), that might be okay. As long as the dependency is 1-way.

    – Keenan Diggs
    Jan 2 at 21:26





















  • I have never built and published a library, but I've noticed that some UI vendors publish individual modules to npm separately. Here's an example of a 3rd party vendor's Dropdown components module. npmjs.com/package/@progress/kendo-angular-dropdowns

    – Keenan Diggs
    Jan 2 at 21:21













  • Thanks Keenan, ya I am thinking maybe this is not possible. Only the ones that import the module have access to their components, etc. I was hoping to do it like this because then I could have one library with each module being a feature

    – L1ghtk3ira
    Jan 2 at 21:24











  • It is starting to look like I need to make a library for each which would be terrible to manage. Or put all components regardless of types like header, footer, tables, all in the library module.

    – L1ghtk3ira
    Jan 2 at 21:24











  • My main thought though is Angular supports it so I would assume it is dooable

    – L1ghtk3ira
    Jan 2 at 21:25











  • If you have a dependency of one module on another (using the BarGraphComponent in your NavigationTopComponent implementation for example), that might be okay. As long as the dependency is 1-way.

    – Keenan Diggs
    Jan 2 at 21:26



















I have never built and published a library, but I've noticed that some UI vendors publish individual modules to npm separately. Here's an example of a 3rd party vendor's Dropdown components module. npmjs.com/package/@progress/kendo-angular-dropdowns

– Keenan Diggs
Jan 2 at 21:21







I have never built and published a library, but I've noticed that some UI vendors publish individual modules to npm separately. Here's an example of a 3rd party vendor's Dropdown components module. npmjs.com/package/@progress/kendo-angular-dropdowns

– Keenan Diggs
Jan 2 at 21:21















Thanks Keenan, ya I am thinking maybe this is not possible. Only the ones that import the module have access to their components, etc. I was hoping to do it like this because then I could have one library with each module being a feature

– L1ghtk3ira
Jan 2 at 21:24





Thanks Keenan, ya I am thinking maybe this is not possible. Only the ones that import the module have access to their components, etc. I was hoping to do it like this because then I could have one library with each module being a feature

– L1ghtk3ira
Jan 2 at 21:24













It is starting to look like I need to make a library for each which would be terrible to manage. Or put all components regardless of types like header, footer, tables, all in the library module.

– L1ghtk3ira
Jan 2 at 21:24





It is starting to look like I need to make a library for each which would be terrible to manage. Or put all components regardless of types like header, footer, tables, all in the library module.

– L1ghtk3ira
Jan 2 at 21:24













My main thought though is Angular supports it so I would assume it is dooable

– L1ghtk3ira
Jan 2 at 21:25





My main thought though is Angular supports it so I would assume it is dooable

– L1ghtk3ira
Jan 2 at 21:25













If you have a dependency of one module on another (using the BarGraphComponent in your NavigationTopComponent implementation for example), that might be okay. As long as the dependency is 1-way.

– Keenan Diggs
Jan 2 at 21:26







If you have a dependency of one module on another (using the BarGraphComponent in your NavigationTopComponent implementation for example), that might be okay. As long as the dependency is 1-way.

– Keenan Diggs
Jan 2 at 21:26














1 Answer
1






active

oldest

votes


















3














You have to export NavigationModule in the LibraryModule, not NavigationSidebarComponent






share|improve this answer
























  • Thanks the module approach I believe is best for a library.

    – L1ghtk3ira
    Jan 3 at 14:16












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%2f54012806%2fangular-library-modules-export-components-services-and-others-from-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









3














You have to export NavigationModule in the LibraryModule, not NavigationSidebarComponent






share|improve this answer
























  • Thanks the module approach I believe is best for a library.

    – L1ghtk3ira
    Jan 3 at 14:16
















3














You have to export NavigationModule in the LibraryModule, not NavigationSidebarComponent






share|improve this answer
























  • Thanks the module approach I believe is best for a library.

    – L1ghtk3ira
    Jan 3 at 14:16














3












3








3







You have to export NavigationModule in the LibraryModule, not NavigationSidebarComponent






share|improve this answer













You have to export NavigationModule in the LibraryModule, not NavigationSidebarComponent







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 4:28









ChristianChristian

1,168714




1,168714













  • Thanks the module approach I believe is best for a library.

    – L1ghtk3ira
    Jan 3 at 14:16



















  • Thanks the module approach I believe is best for a library.

    – L1ghtk3ira
    Jan 3 at 14:16

















Thanks the module approach I believe is best for a library.

– L1ghtk3ira
Jan 3 at 14:16





Thanks the module approach I believe is best for a library.

– L1ghtk3ira
Jan 3 at 14:16




















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%2f54012806%2fangular-library-modules-export-components-services-and-others-from-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

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

Npm cannot find a required file even through it is in the searched directory