@angular/platform-browser#SafeStyle TypeScript Examples
The following examples show how to use
@angular/platform-browser#SafeStyle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: safe.ts From youpez-admin with MIT License | 6 votes |
/**
* Transform
*
* @param value: string
* @param type: string
*/
transform(value: string, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
switch (type) {
case 'html':
return this._sanitizer.bypassSecurityTrustHtml(value)
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:
return this._sanitizer.bypassSecurityTrustHtml(value)
}
}
Example #2
Source File: safe.pipe.ts From open-genes-frontend with Mozilla Public License 2.0 | 6 votes |
public transform(
value: any,
type: string
): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
switch (type) {
case "html":
return this.sanitizer.bypassSecurityTrustHtml(value);
case "style":
return this.sanitizer.bypassSecurityTrustStyle(value);
case "styleUrl":
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return this.sanitizer.bypassSecurityTrustStyle(`url(${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}`);
}
}
Example #3
Source File: safe.pipe.ts From nica-os with MIT License | 6 votes |
public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
switch (type) {
case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
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}`);
}
}
Example #4
Source File: SafePipe.ts From geonetwork-ui with GNU General Public License v2.0 | 6 votes |
public transform(
value: any,
type: string
): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
switch (type) {
case 'html':
return this.sanitizer.bypassSecurityTrustHtml(value)
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}`)
}
}
Example #5
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 6 votes |
getThumbnailLeft(index: number): SafeStyle {
let calculatedIndex;
if (this.order === NgxGalleryOrder.Column) {
calculatedIndex = Math.floor(index / this.rows);
}
else if (this.order === NgxGalleryOrder.Page) {
calculatedIndex = (index % this.columns) + (Math.floor(index / (this.rows * this.columns)) * this.columns);
}
else if (this.order == NgxGalleryOrder.Row && this.remainingCount) {
calculatedIndex = index % this.columns;
}
else {
calculatedIndex = index % Math.ceil(this.images.length / this.rows);
}
return this.getThumbnailPosition(calculatedIndex, this.columns);
}
Example #6
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 6 votes |
getThumbnailTop(index: number): SafeStyle {
let calculatedIndex;
if (this.order === NgxGalleryOrder.Column) {
calculatedIndex = index % this.rows;
}
else if (this.order === NgxGalleryOrder.Page) {
calculatedIndex = Math.floor(index / this.columns) - (Math.floor(index / (this.rows * this.columns)) * this.rows);
}
else if (this.order == NgxGalleryOrder.Row && this.remainingCount) {
calculatedIndex = Math.floor(index / this.columns);
}
else {
calculatedIndex = Math.floor(index / Math.ceil(this.images.length / this.rows));
}
return this.getThumbnailPosition(calculatedIndex, this.rows);
}
Example #7
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 5 votes |
getThumbnailHeight(): SafeStyle {
return this.getThumbnailDimension(this.rows);
}
Example #8
Source File: map.component.ts From geolocation with MIT License | 5 votes |
markerTransform$ = new BehaviorSubject<SafeStyle>('translate(0px,0px)');
Example #9
Source File: image-crop.component.ts From ASW-Form-Builder with MIT License | 5 votes |
marginLeft: SafeStyle | string = '0px';
Example #10
Source File: image-crop.component.ts From ASW-Form-Builder with MIT License | 5 votes |
safeTransformStyle?: SafeStyle | string;
Example #11
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 5 votes |
private getSafeStyle(value: string): SafeStyle {
return this.sanitization.bypassSecurityTrustStyle(value);
}
Example #12
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 5 votes |
private getThumbnailDimension(count: number): SafeStyle {
if (this.margin !== 0) {
return this.getSafeStyle('calc(' + (100 / count) + '% - '
+ (((count - 1) * this.margin) / count) + 'px)');
} else {
return this.getSafeStyle('calc(' + (100 / count) + '% + 1px)');
}
}
Example #13
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 5 votes |
private getThumbnailPosition(index: number, count: number): SafeStyle {
return this.getSafeStyle('calc(' + ((100 / count) * index) + '% + '
+ ((this.margin - (((count - 1) * this.margin) / count)) * index) + 'px)');
}
Example #14
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 5 votes |
getSafeUrl(image: string): SafeStyle {
return this.sanitization.bypassSecurityTrustStyle(this.helperService.getBackgroundUrl(image));
}
Example #15
Source File: brand-icons.stories.ts From canopy with Apache License 2.0 | 5 votes |
cssVar: SafeStyle;
Example #16
Source File: ngx-gallery-thumbnails.component.ts From ngx-gallery-9 with MIT License | 5 votes |
getThumbnailWidth(): SafeStyle {
return this.getThumbnailDimension(this.columns);
}
Example #17
Source File: ngx-gallery-preview.component.ts From ngx-gallery-9 with MIT License | 5 votes |
getTransform(): SafeStyle {
return this.sanitization.bypassSecurityTrustStyle('scale(' + this.zoomValue + ') rotate(' + this.rotateValue + 'deg)');
}
Example #18
Source File: ngx-gallery-image.component.ts From ngx-gallery-9 with MIT License | 5 votes |
getSafeUrl(image: string): SafeStyle {
return this.sanitization.bypassSecurityTrustStyle(this.helperService.getBackgroundUrl(image));
}
Example #19
Source File: chat-message.component.ts From qd-messages-ts with GNU Affero General Public License v3.0 | 5 votes |
avatarStyle: SafeStyle;
Example #20
Source File: platformBrowser.spec.ts From ngx-dynamic-hooks with MIT License | 5 votes |
bypassSecurityTrustStyle(value: string): SafeStyle {
throw new Error('Method not implemented.');
}
Example #21
Source File: icons.stories.ts From canopy with Apache License 2.0 | 5 votes |
colourVar: SafeStyle;