Angular的Ng-Zorro组件库通知提醒框知识点

本文介绍了如何在Angular应用中引入并使用NzNotificationService创建通知提醒框,以及如何根据ID移除特定通知。通过代码示例展示了HTML模板和TypeScript逻辑。


提示:在实际操作中根据id移除通知提醒框的方法尚未熟悉,根据此文档进行巩固

一、在angular中引入通知提醒框服务

  constructor(
        private notifition: NzNotificationService
    ) {}

二、创建通知提醒框

示例图:

html:

 <button
 nz-button
 (click)="personList.onFinish(boxTemplate)"
 nzType="primary" >
       <span>弹出提醒框</span>
 </button> 



<!-- 弹出提示 -->
<ng-template #boxTemplate let-notification let-info="data">
    <div class="ant-notification-notice-content">
        <div class="ant-notification-notice-with-icon">
            <span class="ant-notification-notice-icon">
                <i nz-icon nzType="smile" style="color: rgb(16, 142, 233)"></i>
            </span>
            <div class="ant-notification-notice-message">系统提示:</div>
            <div class="ant-notification-notice-description">xxx</div>

            <span class="ant-notification-notice-btn">
                    <button
                        nz-button
                        nzType="primary"
                        class="mg_l_10"
                    >
                        确定
                    </button>
            </span>
        </div>
    </div>
</ng-template>

ts: 

 personList={
        onUpload: () => {
           //根据id调用remove方法移除
            this.notifition.remove(this.personList.notifition.messageId);
        },
        notifition: null,
        onFinish: (template: TemplateRef<{}>) => {
            this.personList.notifition = this.notifition.template(template, {
                nzDuration: 0,
            });
        },
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值