edit
This commit is contained in:
@ -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';
|
||||
|
||||
2
src/app/shared/pipes/index.ts
Normal file
2
src/app/shared/pipes/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './pipe.module';
|
||||
export * from './trushtml.pipe';
|
||||
10
src/app/shared/pipes/pipe.module.ts
Normal file
10
src/app/shared/pipes/pipe.module.ts
Normal 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 {}
|
||||
29
src/app/shared/pipes/trushtml.pipe.ts
Normal file
29
src/app/shared/pipes/trushtml.pipe.ts
Normal 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 '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user