本文整理汇总了TypeScript中@angular/core.Sanitizer类的典型用法代码示例。如果您正苦于以下问题:TypeScript Sanitizer类的具体用法?TypeScript Sanitizer怎么用?TypeScript Sanitizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sanitizer类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: transform
transform(message: string, replaceUrls: boolean = false): SafeHtml {
if (typeof message === 'string') {
const html = replaceUrls ? SafeHtmlPipe.replaceUrlsWithHtmlLinks(message) : message;
return this.sanitizer.sanitize(SecurityContext.HTML, html);
} else {
return message;
}
}
示例2: factory
factory(alertOptions): any {
var alert = {
type: alertOptions.type,
msg: this.sanitizer.sanitize(SecurityContext.HTML, alertOptions.msg),
id: alertOptions.alertId,
timeout: alertOptions.timeout,
toast: alertOptions.toast,
position: alertOptions.position ? alertOptions.position : 'top right',
scoped: alertOptions.scoped,
close: function (alerts) {
return this.closeAlert(this.id, alerts);
}
};
if (!alert.scoped) {
this.alerts.push(alert);
}
return alert;
}