Simple service to display information banner on the top of the screen
Import NgxBannerModule to your main module, for example, to app.module.ts:
...
import { NgxBannerModule } from 'ngx-banner';
...
@NgModule({
...
imports: [
...
NgxBannerModule,
...
],
...
})
Declare NgxBannerService in target component:
...
import { NgxBannerService } from 'ngx-banner';
...
@Component({
selector: '<component selector>',
})
export class <ComponentName> {
...
constructor(
...
private readonly ngxBannerService: NgxBannerService,
...
) {
...
}
}
Using inside target component (everywhere, ngxBannerService should be declared in target component constructor before):
...
this.ngxBannerService.showBanner({type: 'info', title: 'Banner works', debounceTime: 3000});
...
For now showBanner method has simple configuration:
-
type: 'info' | 'warning' | 'danger'
: banner style: `info means blue, warning means yellow, danger means red.' -
tilte: string
: text that will be displays on banner. -
debounceTime?: number
: time in ms, after which banner will be hidden. This parameter is optional, default value is3000
.