本文整理汇总了TypeScript中@angular/platform-browser.DomSanitizer.bypassSecurityTrustResourceUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DomSanitizer.bypassSecurityTrustResourceUrl方法的具体用法?TypeScript DomSanitizer.bypassSecurityTrustResourceUrl怎么用?TypeScript DomSanitizer.bypassSecurityTrustResourceUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/platform-browser.DomSanitizer
的用法示例。
在下文中一共展示了DomSanitizer.bypassSecurityTrustResourceUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
export const loadSvgResources = (ir: MdIconRegistry, ds: DomSanitizer) => {
const imgDir = 'assets/img';
const sidebarDir = `${imgDir}/sidebar`;
const dayDir = `${imgDir}/days`;
const avatarDir = `${imgDir}/avatar`;
const iconDir = `${imgDir}/icons`;
ir.addSvgIconSetInNamespace('avatars', ds.bypassSecurityTrustResourceUrl(`${avatarDir}/avatars.svg`));
ir.addSvgIcon('unassigned', ds.bypassSecurityTrustResourceUrl(`${avatarDir}/unassigned.svg`));
ir.addSvgIcon('day', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/day.svg`));
ir.addSvgIcon('week', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/week.svg`))
ir.addSvgIcon('month', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/month.svg`));
ir.addSvgIcon('project', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/project.svg`));
ir.addSvgIcon('projects', ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/projects.svg`));
ir.addSvgIcon('move', ds.bypassSecurityTrustResourceUrl(`${iconDir}/move.svg`));
ir.addSvgIcon('add', ds.bypassSecurityTrustResourceUrl(`${iconDir}/add.svg`));
ir.addSvgIcon('delete', ds.bypassSecurityTrustResourceUrl(`${iconDir}/delete.svg`));
const days = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31
]
days.forEach(d => ir.addSvgIcon(`day${d}`, ds.bypassSecurityTrustResourceUrl(`${dayDir}/day${d}.svg`)));
}
示例2: init
public init() {
this.iconRegistry.addSvgIcon(
'add',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/note_add_48px.svg'));
this.iconRegistry.addSvgIcon(
'edit',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/edit_48px.svg'));
this.iconRegistry.addSvgIcon(
'delete',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/delete_forever_48px.svg'));
this.iconRegistry.addSvgIcon(
'calendar',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/calendar.svg'));
this.iconRegistry.addSvgIcon(
'time',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/time.svg'));
this.iconRegistry.addSvgIcon(
'search',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/search.svg'));
this.iconRegistry.addSvgIcon(
'title',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/title.svg'));
this.iconRegistry.addSvgIcon(
'logout',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/logout.svg'));
this.iconRegistry.addSvgIcon(
'arrow_down',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/arrow_down.svg'));
this.iconRegistry.addSvgIcon(
'user',
this.sanitizer.bypassSecurityTrustResourceUrl('assets/icons/user.svg'));
}
示例3: constructor
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
iconRegistry
.addSvgIcon('thumb-up',
sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg'))
.addSvgIconSetInNamespace('core',
sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/core-icon-set.svg'))
.registerFontClassAlias('fontawesome', 'fa');
}
示例4: transform
transform(url) {
if (url) {
const urlWithParameters = this.addURLWithParameters(url);
return this.sanitizer.bypassSecurityTrustResourceUrl(urlWithParameters);
} else {
return this.sanitizer.bypassSecurityTrustResourceUrl('');
}
}
示例5: 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');
}
示例6: constructor
constructor(
private _iconRegistry: MatIconRegistry,
private _domSanitizer: DomSanitizer,
// _translate: TranslateService
) {
this._iconRegistry.addSvgIconInNamespace('assets', 'teradata',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/teradata.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'github',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/github.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'covalent',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/covalent.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'covalent-mark',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/covalent-mark.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'teradata-ux',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/teradata-ux.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'appcenter',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/appcenter.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'listener',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/listener.svg'));
this._iconRegistry.addSvgIconInNamespace('assets', 'querygrid',
this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/querygrid.svg'));
// _translate.setDefaultLang('en');
// _translate.use('en');
}
示例7: buildPlayer
buildPlayer(previewFeeder: boolean, copyFeeder: boolean) {
let cms: string[] = [];
cms.push(`tt=${this.encode(this.title)}`);
cms.push(`ts=${this.encode(this.subtitle)}`);
cms.push(`ui=${this.encode(this.imageUrl)}`);
if (this.feedUrl) {
cms.push(`us=${this.encode(this.feedUrl)}`);
} else {
cms.push(`us=${this.encode(this.subscriptionUrl)}`);
}
if (this.previewingUnpublished && this.enclosureUrl) {
let encUrl = this.previewEnclosure(this.enclosureUrl);
cms.push(`ua=${this.encode(encUrl)}`);
} else {
cms.push(`ua=${this.encode(this.audioUrl)}`);
}
let cmsUrl = `${Env.PLAY_HOST}/e?${cms.join('&')}`;
let feeder: string[] = [];
feeder.push(`uf=${this.encode(this.feedUrl)}`);
feeder.push(`ge=${this.encode(this.episodeGuid)}`);
let feederUrl = `${Env.PLAY_HOST}/e?${feeder.join('&')}`;
// only change the safe resource when the url actually changes
let newPreview = previewFeeder ? feederUrl : cmsUrl;
if (this.previewUrl !== newPreview) {
this.previewUrl = newPreview;
this.previewSafe = this.sanitizer.bypassSecurityTrustResourceUrl(newPreview);
}
this.copyUrl = copyFeeder ? feederUrl : cmsUrl;
this.copyIframe = this.getIframeHtml(this.copyUrl, 650, 200);
}
示例8: transform
transform(value: any, ..._args: any[]): any {
if (!value) {
return null;
}
return this.sanitizer.bypassSecurityTrustResourceUrl(value);
}
示例9: 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}`);
}
}
示例10: 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);
}