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


TypeScript DomSanitizer.bypassSecurityTrustHtml方法代码示例

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


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

示例1: transform

 transform(data: string): SafeHtml {
   if (data) {
     const md = new MarkdownIt();
     md.use(markdownItAttrs);
     return this.sanitizer.bypassSecurityTrustHtml(md.render(data));
   } else {
     return this.sanitizer.bypassSecurityTrustHtml('No Data');
   }
 }
开发者ID:daniru,项目名称:blog,代码行数:9,代码来源:markdown.pipe.ts

示例2: constructor

 constructor(private sanitizer: DomSanitizer) {
   this.imgHtml1 = sanitizer.bypassSecurityTrustHtml(`
     <img class="slide-image" src="resources/images/slides/slide1.png" alt=""/>`);
   this.imgHtml2 = sanitizer.bypassSecurityTrustHtml(`
     <img class="slide-image" src="resources/images/slides/slide2.png" alt=""/>`);
   this.imgHtml3 = sanitizer.bypassSecurityTrustHtml(`
     <img class="slide-image" src="resources/images/slides/slide3.png" alt=""/>`);
   this.imgHtml4 = sanitizer.bypassSecurityTrustHtml(`
     <img class="slide-image" src="resources/images/slides/slide4.png" alt=""/>`);
   this.imgHtml5 = sanitizer.bypassSecurityTrustHtml(`
     <img class="slide-image" src="resources/images/slides/slide5.png" alt=""/>`);      
 }
开发者ID:JavaPantry,项目名称:MockStoreApp,代码行数:12,代码来源:carousel.ts

示例3: constructor

 constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
   iconRegistry
       .addSvgIcon('thumb-up',
           sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg'))
       .addSvgIconLiteral('bike',
           sanitizer.bypassSecurityTrustHtml(BIKE_ICON))
       .addSvgIconSetInNamespace('core',
           sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/core-icon-set.svg'))
       .addSvgIconSetLiteralInNamespace('core-inline',
           sanitizer.bypassSecurityTrustHtml(INLINE_ICON_SET))
       .registerFontClassAlias('fontawesome', 'fa');
 }
开发者ID:Nodarii,项目名称:material2,代码行数:12,代码来源:icon-demo.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

 transform(v: string): SafeHtml {
     let html = this._sanitizer.bypassSecurityTrustHtml(v);
     if (html.hasOwnProperty("changingThisBreaksApplicationSecurity") && /^<p>\d+\./.test(html["changingThisBreaksApplicationSecurity"])) {
         html["changingThisBreaksApplicationSecurity"] = "<p>" + html["changingThisBreaksApplicationSecurity"].substr(html["changingThisBreaksApplicationSecurity"].indexOf('.') + 1);
     }
     return html;
 }
开发者ID:muelletr,项目名称:ultimate-comparison-BASE,代码行数:7,代码来源:sanitizer.pipe.ts

示例6: transform

  transform(value: string) {

    if(!value)
      return value;

    return this.sanitizer.bypassSecurityTrustHtml(value);
  }
开发者ID:iamthelogik83,项目名称:front,代码行数:7,代码来源:safe.ts

示例7:

 .map((paragraph: string, index: number) => {
     return {
         paragraphNo: index,
         safeHtml: this.sanitizer.bypassSecurityTrustHtml(paragraph),
         rawHtml: this.lineNumbering.stripLineNumbers(paragraph)
     };
 });
开发者ID:emanuelschuetze,项目名称:OpenSlides,代码行数:7,代码来源:amendment-create-wizard.component.ts

示例8: Date

                this.forum.getPost( params.get('ID') ).subscribe( post => {
                    this.post = post;
                    this.post.date = (new Date(this.post.date)).toLocaleDateString();
                    this.post['safe_content'] = this.sanitizer.bypassSecurityTrustHtml(this.post.content.rendered);

                    this.post['forum_name'] = forum.getForumName(post);
                }, e => a.toast(e));
开发者ID:JMMgit,项目名称:site,代码行数:7,代码来源:post.page.ts

示例9: transform

  transform(content) {
    if (content) {

      content = this.sanitizer.bypassSecurityTrustHtml(content);
    }
    return content;
  }
开发者ID:jctovar,项目名称:iztacala,代码行数:7,代码来源:sanitize.pipe.ts

示例10: getEnvironmentDescription

 getEnvironmentDescription(): any {
     if (this.environment && this.environment.settings && this.environment.settings.description) {
         return this.sanitizer.bypassSecurityTrustHtml(this.environment.settings.description);
     } else {
         return '';
     }
 }
开发者ID:vfcosta,项目名称:angular-theme,代码行数:7,代码来源:environment-home.component.ts

示例11: transform

 transform(html) {
   //return this.sanitizer.bypassSecurityTrustStyle(html);
    return this.sanitizer.bypassSecurityTrustHtml(html);
   // return this.sanitizer.bypassSecurityTrustScript(value);
   // return this.sanitizer.bypassSecurityTrustUrl(value);
   // return this.sanitizer.bypassSecurityTrustResourceUrl(value);
 }
开发者ID:aballerr,项目名称:hackjavascriptgames,代码行数:7,代码来源:safeHtml.ts

示例12: genDemoTitle

 private genDemoTitle() {
     this.demoStr = this.i18n.fanyi('app.component.examples');
     this.demoContent = this.sanitizer.bypassSecurityTrustHtml(`
         ${this.demoStr}
         <a onclick="window.location.hash='${this.demoStr}'" class="anchor">#</a>
     `);
 }
开发者ID:wexz,项目名称:delon,代码行数:7,代码来源:docs.component.ts

示例13: setPreviewHtml

 private setPreviewHtml(previewHtml) {
   this.preview = this.sanitizer.bypassSecurityTrustHtml(previewHtml)
   setTimeout(() => {
     MathJax.Hub.Queue(['Typeset', MathJax.Hub])
     $('previewer a').attr({target: '_blank'})
   }, 0)
 }
开发者ID:tyfkda,项目名称:JekyllEditor,代码行数:7,代码来源:edit.component.ts

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

示例15: transform

 transform(value:string) {
   if (isBlank(value)) return value;
   if (!isString(value)) {
     throw new InvalidPipeArgumentException(MarkedPipe, value);
   }
   let res = `<span class="redoc-markdown-block">${this.renderer.renderMd(value)}</span>`;
   return this.unstrustedSpec ? res : this.sanitizer.bypassSecurityTrustHtml(res);
 }
开发者ID:rahulyhg,项目名称:ReDoc,代码行数:8,代码来源:pipes.ts


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