如何在其他项目中重用Angular模块 [英] How reuse Angular modules in other projects

查看:52
本文介绍了如何在其他项目中重用Angular模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要与公司中的其他项目共享一个自定义的angular 2模块.

I need to share a custom angular 2 module to other projects in my company.

例如:

@NgModule({
  declarations: [
    AppComponent,
    BannerInlineComponent,
    WelcomeComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class SpecialModule { }

现在,我想在其他项目中使用它:

Now, I want to use it in other projects using:

npm install my-special --save

并使用:

import { SpecialModule } from 'my-special';

推荐答案

我发现使用Yoeman生成器生成角度库的一个选项:

I found one option using Yoeman generator for angular library:

generator-angular2-library

生成器创建模块的基础.

The generator creating a base of your module.

此后,我使用以下方法在本地NPM中模拟了自定义模块的发布:

After this, I simulated the publication of my custom module in local NPM using:

Sinopia

Sinopia码头映像

这篇关于如何在其他项目中重用Angular模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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