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


TypeScript DomSanitizer.bypassSecurityTrustUrl方法代码示例

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


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

示例1: 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

示例2: 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

示例3: constructor

 // #docregion trust-url
 constructor(private sanitizer: DomSanitizer) {
   // javascript: URLs are dangerous if attacker controlled.
   // Angular sanitizes them in data binding, but we can
   // explicitly tell Angular to trust this value:
   this.dangerousUrl = 'javascript:alert("Hi there")';
   this.trustedUrl = sanitizer.bypassSecurityTrustUrl(this.dangerousUrl);
   // #enddocregion trust-url
   this.updateVideoUrl('PUBnlbjZFAI');
 }
开发者ID:SaloGala,项目名称:angular-es,代码行数:10,代码来源:bypass-security.component.ts

示例4: 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

示例5: Blob

        this.gridContext.gridToCsv().then(csv => {
            const blob = new Blob([csv], {type : 'text/plain'});
            const win: any = window; // avoid TS errors
            this.csvExportUrl = this.sanitizer.bypassSecurityTrustUrl(
                (win.URL || win.webkitURL).createObjectURL(blob)
            );

            // Fire the 2nd click event now that the browser has
            // information on how to download the CSV file.
            setTimeout(() => $event.target.click());
        });
开发者ID:StephenGWills,项目名称:Evergreen,代码行数:11,代码来源:grid-toolbar.component.ts

示例6: ngOnInit

  ngOnInit(){

    //this.v1cleaned = this.sanitizer.bypassSecurityTrustUrl('//www.youtube.com/embed/FQSSsmTroMk');
    //this.v1 = this.v1cleaned.changingThisBreaksApplicationSecurity;
    this.v1 = this.sanitizer.bypassSecurityTrustUrl('youtube.com/embed/FQSSsmTroMk');

  

    
      const VIDEOS: Video[] = [
        { Title: "Church Window Cookies", EmbedUrl: '//www.youtube.com/embed/FQSSsmTroMk' },
        { Title: "Pasta with Meat Sauce", EmbedUrl: '//www.youtube.com/embed/_MIdbZml6r4?list=UUpLxEusuFWB8cZXyiXs4qew' },
        { Title: "Pizza", EmbedUrl: '//www.youtube.com/embed/i9QToeYHTmQ' },
        { Title: "Kale Salad", EmbedUrl: '//www.youtube.com/embed/1eqjq_eoeQM' },
        { Title: "Maple Syrup Snow Candy", EmbedUrl: '//www.youtube.com/embed/5e5MUxhmBWk' },        
      ];

      this.videos = VIDEOS;
  }
开发者ID:jlooper,项目名称:quicknoms,代码行数:19,代码来源:videos.component.ts

示例7: toSafeUrl

 private toSafeUrl(iconPath: string): SafeUrl {
   return this.sanitizer.bypassSecurityTrustUrl(iconPath);
 }
开发者ID:gnodet,项目名称:syndesis,代码行数:3,代码来源:icon-path.pipe.ts

示例8: sanitizeUrl

 sanitizeUrl(url: string) {
   return this.sanitizer.bypassSecurityTrustUrl(url);
 }
开发者ID:ArielEspinoza07,项目名称:SearchFrontAngular,代码行数:3,代码来源:video.component.ts

示例9:

 ads.map(async ad => {
   const img = await this.imgcache.getCachedFile(ad.app_imageurl);
   ad.app_imageurl = this.sanitizer.bypassSecurityTrustUrl(img) as string;
   return ad;
 }),
开发者ID:ifiske,项目名称:iFiske,代码行数:5,代码来源:ads.ts

示例10: transform

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


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