文章页正文上
Angular serviceTemplateRefAngular serviceTemplateRef NzNotificationService.template
template(template:TemplateRef,options?:NzNotificationDataOptions):NzNotificationRef;
TemplateRef service NzNotificationService.template
service html template service html ng-template
dom service
import{Injectable,TemplateRef}from'@angular/core'; import{NzNotificationService}from'ng-zorro-antd/notification'; exportenumEMessageCode{ XXXError=1024, YYYError=1025, } exportconstMESSAGE={ [EMessageCode.XXXError]:'XXXError...', [EMessageCode.YYYError]:'YYYError...', }; @Injectable({ providedIn:'root', }) exportclassMessageService{ privatetemplateMap=newMap(); constructor(privatenotificationService:NzNotificationService){} //templateRef publicinitTemplate(message:EMessageCode,ref:TemplateRef):void{ this.templateMap.set(message,ref); } publicshowMessage(messageCode:EMessageCode){ switch(messageCode){ caseEMessageCode.XXXError: returnthis.notificationService.template(this.templateMap.get(messageCode),{ nzDuration:0, }); caseEMessageCode.YYYError:{ returnthis.notificationService.error('YYYError',MESSAGE[EMessageCode.YYYError]); } } } publicremoveMessage(messageId?:string){ this.notificationService.remove(messageId); } }
import{Component,TemplateRef,ViewChild,AfterViewInit}from'@angular/core'; import{EMessageCode,MessageService}from'./message.service'; @Component({ selector:'app-message-service-virtual-ref', template:`ThereareXXXError,youmustreferto something tocheckout`, }) exportclassMessageServiceVirtualRefComponentimplementsAfterViewInit{ @ViewChild('xxx_ref')xxxTemplateRef!:TemplateRef; constructor(privatemessageService:MessageService){} ngAfterViewInit():void{ this.messageService.initTemplate(免费云主机、域名EMessageCode.XXXError,this.xxxTemplateRef); } }
Angular serviceTemplateRef
这篇文章主要介绍“javascript支不支持求余数的方法”,在日常操作中,相信很多人在javascript支不支持求余数的方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”javascript支不支持求余数的方法”的疑惑有所帮…
文章页内容下