@angular/platform-browser#SafeHtml TypeScript Examples

The following examples show how to use @angular/platform-browser#SafeHtml. 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.pipe.ts    From nica-os with MIT License 6 votes vote down vote up
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 #2
Source File: safe.ts    From youpez-admin with MIT License 6 votes vote down vote up
/**
   * 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 #3
Source File: safe.pipe.ts    From open-genes-frontend with Mozilla Public License 2.0 6 votes vote down vote up
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 #4
Source File: SafePipe.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
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: dom-sanitizer.pipe.ts    From loopback4-microservice-catalog with MIT License 5 votes vote down vote up
transform(html: string): SafeHtml {
      return this.domSanitizer.bypassSecurityTrustHtml(html);
   }
Example #6
Source File: platformBrowser.spec.ts    From ngx-dynamic-hooks with MIT License 5 votes vote down vote up
bypassSecurityTrustHtml(value: string): SafeHtml {
    throw new Error('Method not implemented.');
  }
Example #7
Source File: preview.service.ts    From sba-angular with MIT License 5 votes vote down vote up
/**
     * Sanitize the text of a HTML formatted extract
     * @param text
     */
    private sanitize(text?: string): SafeHtml | string {
        return text? this.domSanitizer.bypassSecurityTrustHtml(text.replace(/sq\-current/, "")) : "";
    }
Example #8
Source File: preview.service.ts    From sba-angular with MIT License 5 votes vote down vote up
text: SafeHtml;
Example #9
Source File: icon.component.ts    From ng-icons with MIT License 5 votes vote down vote up
/** Store the formatted icon name */
  @HostBinding('innerHTML') template?: SafeHtml;
Example #10
Source File: safe.pipe.ts    From wingsearch with GNU General Public License v3.0 5 votes vote down vote up
transform(value: string, ...args: unknown[]): SafeHtml {
    return this.sanitizer.bypassSecurityTrustHtml(value)
  }
Example #11
Source File: safe-html.pipe.ts    From tabby with MIT License 5 votes vote down vote up
transform(value: string): SafeHtml {
    return this._DomSanitizer.bypassSecurityTrustHtml(value)
  }
Example #12
Source File: safe-html.pipe.ts    From dating-client with MIT License 5 votes vote down vote up
transform(html: string): SafeHtml {
    return this.sanitizer.bypassSecurityTrustHtml(html);
  }
Example #13
Source File: nosanitizepipe.ts    From careydevelopmentcrm with MIT License 5 votes vote down vote up
transform(html: string): SafeHtml {
    return this.domSanitizer.bypassSecurityTrustHtml(html);
  }
Example #14
Source File: licenses.component.ts    From blockcore-hub with MIT License 5 votes vote down vote up
selectedContent: SafeHtml;
Example #15
Source File: trust-html.pipe.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
public transform(value: string): SafeHtml {
    return this._sanitizer.bypassSecurityTrustHtml(value);
  }
Example #16
Source File: about.component.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
public trustHtml(html: string): SafeHtml {
    return this._sanitizer.bypassSecurityTrustHtml(html);
  }
Example #17
Source File: sanitize-html.pipe.ts    From SideQuest with MIT License 5 votes vote down vote up
transform(v:string):SafeHtml {
    return this._sanitizer.bypassSecurityTrustHtml(v);
  }
Example #18
Source File: mermaid-viewer.component.ts    From visualization with MIT License 5 votes vote down vote up
public svg$: BehaviorSubject<SafeHtml | null> = new BehaviorSubject<SafeHtml | null>(null);
Example #19
Source File: mermaid-viewer.component.ts    From visualization with MIT License 5 votes vote down vote up
@Input() public safeSvg!: SafeHtml;