@acpaas-ui/ngx-notifications 中文文档教程

发布于 3年前 浏览 12 更新于 3年前

@acpaas-ui/ngx-notifications

允许使用简单通知来显示成功、错误或警告消息的模块。

Usage

将模块导入您的应用程序:

import { NotificationsModule } from '@acpaas-ui/ngx-notifications';

@NgModule({
    imports: [
        NotificationsModule,
        BrowserAnimationsModule
    ]
})
export class AppModule {}

请注意,您必须手动在根应用程序模块中导入 BrowserAnimationsModule

在组件中使用通知:

import { NotificationsService } from '@acpaas-ui/ngx-notifications';

@Component({...})
export class AppComponent {

    constructor(private service: NotificationsService) {}

    showInfoNotificationNotification() {
      this.notificationsService.info('This is the body of an info notification.', 'Info');
    }

    showSuccessNotification() {
      this.notificationsService.success('This is the body of a success notification.', 'Success');
    }

    showWarningNotification() {
      this.notificationsService.warning('This is the body of a warning notification', 'Warning');
    }

    showErrorNotification() {
      this.notificationsService.error('This is the body of an error notification', 'Error');
    }
}

我们的通知包基于 ngx-toastr 构建。 ngx-toastr NPM 页面 列出了所有可用选项。

@acpaas-ui/ngx-notifications

Module that allows the use of a simple notification to display success, error or warning messages.

Usage

Import the module into your application:

import { NotificationsModule } from '@acpaas-ui/ngx-notifications';

@NgModule({
    imports: [
        NotificationsModule,
        BrowserAnimationsModule
    ]
})
export class AppModule {}

Note that you manually have to import the BrowserAnimationsModule in your root application module.

Use the notification in a component:

import { NotificationsService } from '@acpaas-ui/ngx-notifications';

@Component({...})
export class AppComponent {

    constructor(private service: NotificationsService) {}

    showInfoNotificationNotification() {
      this.notificationsService.info('This is the body of an info notification.', 'Info');
    }

    showSuccessNotification() {
      this.notificationsService.success('This is the body of a success notification.', 'Success');
    }

    showWarningNotification() {
      this.notificationsService.warning('This is the body of a warning notification', 'Warning');
    }

    showErrorNotification() {
      this.notificationsService.error('This is the body of an error notification', 'Error');
    }
}

Our notifications package is built on ngx-toastr. All available options are listed on the ngx-toastr NPM page.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文