JSPM

  • Created
  • Published
  • Downloads 6073
  • Score
    100M100P100Q151575F
  • License MIT

Simple safe pipe for sanitizing your safe content

Package Exports

  • safe-pipe

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (safe-pipe) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Resolve your safe content with Angular SafePipe

NPM

Install via npm

$ npm install --save safe-pipe

Usage example:

// app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { SafePipeModule } from 'safe-pipe';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    SafePipeModule,
    BrowserModule
  ]
  bootstrap: [ AppComponent ]
})
export class AppModule { }

// app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <div [style.background-image]="'url(' + catPictureUrl + ')' | safe: 'style'"></div>
    <img [src]="catPictureUrl | safe: 'url'" alt="A Cat">
    <iframe width="640" height="390" [src]="catVideoEmbed | safe: 'resourceUrl'"></iframe>
  `
})
export class AppComponent {
  public htmlContent: string = `<h1>Lorem ipsum dolor sit amet.</h1>`;
  public catPictureUrl: string = `https://www.petdrugsonline.co.uk/images/page-headers/cats-master-header`;
  public catVideoEmbed: string = `https://www.youtube.com/embed/QH2-TGUlwu4"`;
}