如何在多个Angular 2项目之间共享Angular 2组件? [英] How can I share an Angular 2 component between multiple Angular 2 projects?

查看:157
本文介绍了如何在多个Angular 2项目之间共享Angular 2组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

理想情况下,我想创建一个独立的Angular 2组件(带有测试),然后在两个或三个不同的Angular 2站点之间重新使用它。实现这一目标的好方法是什么?
和奖金问题 - 是否存在任何第三方Angular 2组件?

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?

推荐答案

您可以创建一个angular2组件库(带有测试),然后在任意数量的项目中使用它

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

以下是如何创建angular2库
https://makina-corpus.com/blog/metier/2017/how-to-create-an-angular-library

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

然后您也可以将其发布供公众使用。如果您想将其保密,可以阅读 https://www.npmjs.com/onsite

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

是的,存在许多第三方angular2组件。以下是来自valor-software https://github.com/valor-software/ng2-plans

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

角度库的Yeoman Generator https://github.com/jvandemo/generator-angular2-library

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

这篇关于如何在多个Angular 2项目之间共享Angular 2组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆