Skip to main content

Notices

Notices are designed to serve as simple user notifications. NgOP does not define how those notifications will look like, it will only maintain them for you.

All you need to do is to define components that will represent those notices in your application. Note that they will not be used as container components like by modals. The idea here is to prevent too much customisation of those components.

Creating default notice component

Plugin requires user to provide all available notice components by module initialisation.

We will have to create a component that will represent a default notice.

@Component({
template: 'This is a default notice.',
})
export class DefaultNoticeComponent {}

Initialisation

notices configuration expects an object that represents notices components with their assigned names. For example, if we would have a component called DefaultNoticeComponent that would represent default notice container, we could assign it as "default".

OpCoreModule.forRoot({
notices: {
default: DefaultNoticeComponent,
},
})

We can also add other notice components and assign them different names. Let's assume we have a component called InfoNoticeComponent and WarningNoticeComponent. We can assign them names "info" and "warning".

OpCoreModule.forRoot({
modals: {
default: DefaultModalComponent,
info: InfoNoticeComponent,
warning: WarningNoticeComponent,
},
})

Now when you will be opening notices you will be able to specify which component should NgOP use.

...

Injecting service

Inject OpNoticesService in your component

@Component({ ... })
export class SomeComponent {
constructor(private noticesService: OpNoticesService) {}
}

Showing notices

...