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 || "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue