angular - 如何使用 ngx-bootstrap 创建通用通知,如 toastr 通知

标签 angular push-notification angular2-services

我是 Angular 2 和 4 的新手。我想使用 ngx-bootstrap 警报和模态创建自定义通知。我已经搜索并获得了一些样本。但这些并不简单。我只需要一个简单的蓝图来创建带有服务、接口(interface)和组件的通知。

请任何人用示例代码指导我。

最佳答案

ngx-bootstrap 的官方文档 - Alerts .
ngx-bootstrap 的官方文档 - Modals .
那里提供 API 文档和使用场景以及实际示例。


为了快速引用,我会给你一个简单的警告框的代码——下面的用法和演示:

首先,使用以下方法在您的 Root 模块中导入 ngx-bootstrap:

import { AlertModule } from 'ngx-bootstrap';

@NgModule({
  imports: [AlertModule.forRoot(),...]
})
export class AppModule(){}

这是 HTML 部分模板:

<alert type="success">
  <strong>Well done!</strong> You successfully read this important alert message.
</alert>

Component 代码如下:

import { Component } from '@angular/core';

@Component({
  selector: 'demo-alert-basic',
  templateUrl: './basic.html'
})
export class DemoAlertBasicComponent {}

关于angular - 如何使用 ngx-bootstrap 创建通用通知,如 toastr 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45182811/

相关文章:

ios - APN(Apple 推送通知)负载大小限制

java - Android 推送通知 - 在满足条件之前不可删除的推送通知

angular - EventEmitter 的正确用法是什么?

javascript - 如何将服务注入(inject)到类中,然后用它扩展组件?

angular - 从容器外部访问 dockerized 节点应用程序时出现问题

javascript - 在输入字段中输入后如何添加符号?

ios - RemoteNotification 来自 launchOptions

typescript - 在异步调用中订阅 Observable 不起作用 [Angular2]

当从 api 获取数据时,Angular 2+ 用 ngFor 填充 html 表

angular - 如何使用相对导航导航到 Angular 4 中的同级?