How can I share an Angular 2 component between multiple Angular 2 projects?

Tags: , ,



Ideally, I’d like to create a stand-alone Angular 2 component (with tests) and then re-use it between two or three different Angular 2 sites. What are the good ways to achieve this?
And a bonus question – do any 3rd party Angular 2 components exist?

Answer

UPDATE

OFFICIAL Angular CLI https://angular.io/guide/creating-libraries

You can create an angular2 component library (with tests) and then use it in any number of projects

Here’s how to create an angular2 library
https://makina-corpus.com/blog/metier/2017/how-to-create-an-angular-library

with angular-cli https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e

Then you can publish it for public use as well. If you want to keep it private, you can read this https://www.npmjs.com/onsite

Yes, many 3rd party angular2 components exist. Here are few from valor-software https://github.com/valor-software/ng2-plans


Yeoman Generator for angular library https://github.com/jvandemo/generator-angular2-library



Source: stackoverflow