当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript DomSanitizer.bypassSecurityTrustScript方法代码示例

本文整理汇总了TypeScript中@angular/platform-browser.DomSanitizer.bypassSecurityTrustScript方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DomSanitizer.bypassSecurityTrustScript方法的具体用法?TypeScript DomSanitizer.bypassSecurityTrustScript怎么用?TypeScript DomSanitizer.bypassSecurityTrustScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/platform-browser.DomSanitizer的用法示例。


在下文中一共展示了DomSanitizer.bypassSecurityTrustScript方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: transform

 public transform(
   value: any,
   type: string
 ): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
   switch (type) {
     case "html":
       return this.sanitizer.bypassSecurityTrustHtml(
         `${value}`.replace(/<p[^>]*>/g, "").replace(/<strong[^>]*>/g, "")
       );
     case "text":
       const span = document.createElement("span");
       span.innerHTML = value;
       return span.textContent || span.innerText;
     case "style":
       return this.sanitizer.bypassSecurityTrustStyle(value);
     case "script":
       return this.sanitizer.bypassSecurityTrustScript(value);
     case "url":
       return this.sanitizer.bypassSecurityTrustUrl(value);
     case "resourceUrl":
       return this.sanitizer.bypassSecurityTrustResourceUrl(value);
     default:
       throw new Error(`Invalid safe type specified: ${type}`);
   }
 }
开发者ID:strandls,项目名称:biodiv-mobile,代码行数:25,代码来源:safe.pipe.ts

示例2: transform

	transform(value: any, context?: SecurityContext | string | String) {
		if (!value) {
			return value;
		}
		if (typeof context === "undefined") {
			context = SecurityContext.HTML;
		}
		if (context instanceof String) {
			context = context.toString();
		}
		if (typeof context === "string" || context instanceof String) {
			context = SecurityContext[context.replace("-", "_").toUpperCase()];
		}
		switch (context) {
			case SecurityContext.HTML:
				return this.domSanitizer.bypassSecurityTrustHtml(value);
			case SecurityContext.RESOURCE_URL:
				return this.domSanitizer.bypassSecurityTrustResourceUrl(value);
			case SecurityContext.SCRIPT:
				return this.domSanitizer.bypassSecurityTrustScript(value);
			case SecurityContext.STYLE:
				return this.domSanitizer.bypassSecurityTrustStyle(value);
			case SecurityContext.URL:
				return this.domSanitizer.bypassSecurityTrustUrl(value);
		}
		return this.domSanitizer.sanitize(context as SecurityContext, value);
	}
开发者ID:nibo-ai,项目名称:nit-pipes,代码行数:27,代码来源:safe.pipe.ts

示例3: transform

 public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
   switch (type) {
     case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
     case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
     case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
     case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
     case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
     default: throw new Error(`Invalid safe type specified: ${type}`);
   }
 }
开发者ID:macliems,项目名称:JixyFront,代码行数:10,代码来源:safe-pipe.ts

示例4: transform

	transform(value: any): any {
		return this.sanitizer.bypassSecurityTrustScript(value);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-Mobile,代码行数:3,代码来源:safe.ts


注:本文中的@angular/platform-browser.DomSanitizer.bypassSecurityTrustScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。