Feat: created pipe only for strip html; Feat: created example project;
This commit is contained in:
parent
30284843fb
commit
fd2734d0da
47 changed files with 22064 additions and 0 deletions
15
src/directives/ngx-stripper.pipe.ts
Normal file
15
src/directives/ngx-stripper.pipe.ts
Normal 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
1
src/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from './ngx-stripper.module';
|
||||
23
src/ngx-stripper.module.ts
Normal file
23
src/ngx-stripper.module.ts
Normal 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: []
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue