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


TypeScript DomSanitizer.bypassSecurityTrustStyle方法代码示例

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


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

示例1: getLevelStyle

  public getLevelStyle(): SafeStyle {
    let level = this.device.Level;

    let safeStyle: SafeStyle = this.sanitizer.bypassSecurityTrustStyle( `width: 0%`);
    if(this.device.SwitchType === 'Dimmer' && (this.device.Data === 'On' || this.device.Data.startsWith('Set Level')))
      safeStyle = this.sanitizer.bypassSecurityTrustStyle( `width: ${level}%`);
    else if(this.device.Data === 'On')
      safeStyle = this.sanitizer.bypassSecurityTrustStyle( `width: 100%`);
    return safeStyle;
  }
开发者ID:robsonke,项目名称:domotica-app,代码行数:10,代码来源:device.component.ts

示例2: transform

  transform(sentiment: Sentiment): string|SafeStyle {
    if (!sentiment) {
      return '';
    }

    let style = '';

    // Change font based on positive/negative score.
    if (sentiment.score >= 0.9) {
      style += `font-family: 'Bonbon', 'Roboto', 'Helvetica', sans-serif;`;
    } else if (sentiment.score >= 0.5) {
      style += `font-family: 'Crafty Girls', 'Roboto', 'Helvetica', sans-serif;`;
    } else if (sentiment.score <= -0.9) {
      style += `font-family: 'Creepster', 'Roboto', 'Helvetica', sans-serif;`;
    } else if (sentiment.score <= -0.5) {
      style += `font-family: 'Julee', 'Roboto', 'Helvetica', sans-serif;`;
    }

    // Make bold if the magnitude is greater than 1.
    if (sentiment.magnitude >= 1) {
      style += `font-weight: bold;`;
    }

    return style ? this.sanitizer.bypassSecurityTrustStyle(style) : '';
  }
开发者ID:Sidibedev,项目名称:friendlychat,代码行数:25,代码来源:stylize.pipe.ts

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

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

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

示例6: constructor

  constructor(
    navParams: NavParams,
    tagIndexService: TagIndexService,
    settings: Settings,
    sanitizer: DomSanitizer,
    private navCtrl: NavController,
    private wikiPageService: WikiPageService) {

    this.tag = navParams.get("tag");
    tagIndexService.getFilesForTag(this.tag)
      .then(fileNames => this.pageNames = fileNames.map(x => wikiPageService.getPageNameFromFile(x)));

    this.styleGrey = settings.getStyle() === "Grey";
    this.fontPctStyle = sanitizer.bypassSecurityTrustStyle("font-size: " + settings.getFontSize() + "%");
  }
开发者ID:janwillemb,项目名称:Ema-Personal-Wiki,代码行数:15,代码来源:tag.ts

示例7: makeDialogStyles

 makeDialogStyles(): SafeStyle {
   const width: string = this.width ? `width: ${this.width};` : ''
   const styles: string = `top: ${this.top};${width}`
   return this.sanitizer.bypassSecurityTrustStyle(styles)
 }
开发者ID:weiwang94,项目名称:element-angular,代码行数:5,代码来源:dialog.ts

示例8: transform

 transform(style) {
   return this.domSanitizer.bypassSecurityTrustStyle(style);
 }
开发者ID:icebluetech,项目名称:process-improvement-app,代码行数:3,代码来源:data.ts

示例9: transform

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

示例10: sanitizeImage

 public sanitizeImage(image: string): SafeStyle {
   return this._sanitizer.bypassSecurityTrustStyle('url(' + image + ')');
 }
开发者ID:MichaelSolati,项目名称:ng-portfolio,代码行数:3,代码来源:articles.component.ts

示例11: transform

 transform(style): SafeStyle {
   return this.sanitizer.bypassSecurityTrustStyle(style);
 }
开发者ID:blmsl,项目名称:memories,代码行数:3,代码来源:safe-style.pipe.ts

示例12: ngOnChanges

 public ngOnChanges(changes: {[propName: string]: SimpleChange}): void {
     let val = this.resource.properties.rgbValue;
     this.style = this.sanitizer.bypassSecurityTrustStyle(
             'background:rgb(' + val[0] + ',' + val[1] + ',' + val[2] + ')');
 }
开发者ID:baleboy,项目名称:zephyrjs-ide,代码行数:5,代码来源:ocf-explorer.resource.value.rgbled.component.ts

示例13: transform

 transform(value: any, args: any[]): any {
   return this.santizier.bypassSecurityTrustStyle(value);
 }
开发者ID:Yakindu,项目名称:examples,代码行数:3,代码来源:y-trust-style.pipe.ts

示例14: transform

 /**
  * Sanitizes the string allowing it to be injected into a template
  * @param style String to sanitize
  * @return Sanitized string
  */
  public transform(style: string): any {
      return this.sanitizer.bypassSecurityTrustStyle(style);
  }
开发者ID:acaprojects,项目名称:a2-widgets,代码行数:8,代码来源:safe-style.pipe.ts

示例15: constructor

 constructor(private sanitizer: DomSanitizer) {
    this.backgroundImage = this.sanitizer.bypassSecurityTrustStyle(`url('${images.background}')`);
 }
开发者ID:presidential-innovation-fellows,项目名称:code-gov-web,代码行数:3,代码来源:hero-header.component.ts


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