ngx-eventbus - ngx-eventbus is an angular open source library that simplifies the communication between angular directives and components - reuse the events instead of duplicating the code <3 - Angular V7 supported
View all the directives in action at https://anthonynahas.github.io/ngx-eventbus
- Angular (requires Angular 2 or higher, tested with 2.0.0)
Install above dependencies via npm.
Now install ngx-eventbus
via:
npm install --save ngx-eventbus
Note:If you are using
SystemJS
, you should adjust your configuration to point to the UMD bundle. In your systemjs config file,map
needs to tell the System loader where to look forngx-eventbus
:
map: {
'ngx-eventbus': 'node_modules/ngx-eventbus/bundles/ngx-eventbus.umd.js',
}
Once installed you need to import the main module:
import { LibModule } from 'ngx-eventbus';
The only remaining part is to list the imported module in your application module. The exact method will be slightly
different for the root (top-level) module for which you should end up with the code similar to (notice LibModule .forRoot()
):
import { LibModule } from 'ngx-eventbus';
@NgModule({
declarations: [AppComponent, ...],
imports: [LibModule.forRoot(), ...],
bootstrap: [AppComponent]
})
export class AppModule {
}
Other modules in your application can simply import LibModule
:
import { LibModule } from 'ngx-eventbus';
@NgModule({
declarations: [OtherComponent, ...],
imports: [LibModule, ...],
})
export class OtherModule {
}
Copyright (c) 2018 Anthony Nahas. Licensed under the MIT License (MIT)