當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。