import { Injectable } from '@angular/core' ; import { NzModalService } from 'ng-zorro-antd' ; @ Injectable ( ) export class MessageService { constructor ( private modalSrv ) { } info ( message , title = "通知信息" ) { this . modalSrv . info ( { title : title , content : message } ) ; } success ( message , title = "成功信息" ) { this . modalSrv . success ( { title : title , content : message } ) ; } warn ( message , title = "警告信息" ) { this . modalSrv . warning ( { title : title , content : message } ) ; } error ( message , title = "失败信息" ) { this . modalSrv . error ( { title : title , content : message } ) ; } confirm ( message , titleOrCallBack ? , callback ? ) { if ( typeof titleOrCallBack == 'string' ) { this . modalSrv . confirm ( { title : titleOrCallBack , content : message , onOk ( ) { if ( callback ) callback ( true ) ; } , onCancel ( ) { if ( callback ) callback ( false ) ; } } ) ; } else { this . modalSrv . confirm ( { title : "确认操作" , content : message , onOk ( ) { if ( titleOrCallBack ) titleOrCallBack ( true ) ; } , onCancel ( ) { if ( titleOrCallBack ) titleOrCallBack ( false ) ; } } ) ; } } }