This commit is contained in:
Taric Xin
2021-12-27 18:27:08 +08:00
parent 7e6d86d00e
commit 786c2e1bad
13 changed files with 104 additions and 84 deletions

View File

@ -22,6 +22,7 @@ export * from './components/dict-select/index';
// Utils
export * from './utils';
export * from './services';
export * from './pipes';
// Module
export * from './shared.module';

View File

@ -0,0 +1,2 @@
export * from './pipe.module';
export * from './trushtml.pipe';

View File

@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TrushtmlPipe } from './trushtml.pipe';
@NgModule({
declarations: [TrushtmlPipe],
imports: [CommonModule],
exports: [TrushtmlPipe]
})
export class PipeModule {}

View File

@ -0,0 +1,29 @@
/*
* @Description:
* @Author: wsm
* @Date: 2021-06-23 17:02:20
* @LastEditTime: 2021-06-23 17:04:57
* @LastEditors: wsm
* @Reference:
*/
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: 'safehtml',
})
export class TrushtmlPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
transform(value: any, args?: any): any {
try {
if (!value || value === '') {
return '';
}
return this.sanitizer.bypassSecurityTrustHtml(value);
} catch (e) {
console.warn(e);
return '';
}
}
}

View File

@ -30,6 +30,7 @@ import { LogisticsTimeLineComponent } from './components/logistics-time-line/log
import { AmapModule } from './components/amap/amap.module';
import { ImageListModule } from './components/imagelist';
import { DictSelectComponent } from './components/dict-select';
import { PipeModule } from './pipes';
const MODULES = [
AddressModule,
@ -43,6 +44,7 @@ const MODULES = [
SharedThirdModule,
AmapModule,
ImageListModule,
PipeModule,
...PRO_SHARED_MODULES
];
// #endregion