How reuse Angular modules in other projects

此生再无相见时 提交于 2021-02-07 18:10:33

问题


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

For example:

@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

And use:

import { SpecialModule } from 'my-special';

回答1:


I found one option using Yoeman generator for angular library:

generator-angular2-library

The generator creating a base of your module.

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

Sinopia

Sinopia docker image



来源:https://stackoverflow.com/questions/43220150/how-reuse-angular-modules-in-other-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!