本文整理匯總了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');
}
}
示例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=""/>`);
}
示例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');
}
示例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);
}
示例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;
}
示例6: transform
transform(value: string) {
if(!value)
return value;
return this.sanitizer.bypassSecurityTrustHtml(value);
}
示例7:
.map((paragraph: string, index: number) => {
return {
paragraphNo: index,
safeHtml: this.sanitizer.bypassSecurityTrustHtml(paragraph),
rawHtml: this.lineNumbering.stripLineNumbers(paragraph)
};
});
示例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));
示例9: transform
transform(content) {
if (content) {
content = this.sanitizer.bypassSecurityTrustHtml(content);
}
return content;
}
示例10: getEnvironmentDescription
getEnvironmentDescription(): any {
if (this.environment && this.environment.settings && this.environment.settings.description) {
return this.sanitizer.bypassSecurityTrustHtml(this.environment.settings.description);
} else {
return '';
}
}
示例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);
}
示例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>
`);
}
示例13: setPreviewHtml
private setPreviewHtml(previewHtml) {
this.preview = this.sanitizer.bypassSecurityTrustHtml(previewHtml)
setTimeout(() => {
MathJax.Hub.Queue(['Typeset', MathJax.Hub])
$('previewer a').attr({target: '_blank'})
}, 0)
}
示例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}`);
}
}
示例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);
}