Feat: created pipe only for strip html; Feat: created example project;

This commit is contained in:
Lorenzo Iovino 2019-05-08 11:21:51 +02:00
parent 30284843fb
commit fd2734d0da
47 changed files with 22064 additions and 0 deletions

View file

@ -0,0 +1,15 @@
import {
Pipe, PipeTransform
} from '@angular/core';
@Pipe({ name: 'stripper' })
export class NgxStripperPipe implements PipeTransform {
transform(inputString: string, type: 'html') {
if(type === 'html' || !type) {
const htmlEl = document.createElement("div");
htmlEl.innerHTML = inputString;
return htmlEl.textContent || htmlEl.innerText || "";
}
}
}

1
src/index.ts Normal file
View file

@ -0,0 +1 @@
export * from './ngx-stripper.module';

View file

@ -0,0 +1,23 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {NgxStripperPipe} from './directives/ngx-stripper.pipe';
@NgModule({
declarations: [
NgxStripperPipe
],
exports: [
NgxStripperPipe
],
imports: [
CommonModule
]
})
export class NgxStripperModule {
static forRoot() {
return {
ngModule: NgxStripperModule,
providers: []
};
}
}