How to write Angular2 npm module - Angular2 RC 6

When you make a module, you should be sure that it imports the modules and declares the components that it uses, as well as export anything that should be available to consumers. Ex:

@NgModule({
  imports: [...modulesImConsuming],
  exports: [...modulesAndComponentsMyConsumersNeed],
  declarations: [...myModulesComponents]
})

In your instance, we would have (note the declarations change):

@NgModule({
    declarations: [NgGrid, NgGridItem],
    imports: [
        BrowserModule,
        CommonModule
    ],
    exports: [NgGrid, NgGridItem]
})

Then to consume our module, we just need to import it. When importing a module we get access to all components (NgGrid, NgGridItem) as well as any modules (and everything the exported module exports and so on) that are exported. In your case we would have:

@NgModule({
  imports: [FlexboxGridModule]
})

Tags:

Npm

Angular