ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
34 lines • 4.17 kB
JavaScript
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
import { Pipe } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
export class NzSanitizerPipe {
constructor(sanitizer) {
this.sanitizer = sanitizer;
}
transform(value, type = 'html') {
switch (type) {
case 'html':
return this.sanitizer.bypassSecurityTrustHtml(value);
case 'style':
return this.sanitizer.bypassSecurityTrustStyle(value);
case 'url':
return this.sanitizer.bypassSecurityTrustUrl(value);
case 'resourceUrl':
return this.sanitizer.bypassSecurityTrustResourceUrl(value);
default:
throw new Error(`Invalid safe type specified`);
}
}
}
NzSanitizerPipe.decorators = [
{ type: Pipe, args: [{
name: 'nzSanitizer'
},] }
];
NzSanitizerPipe.ctorParameters = () => [
{ type: DomSanitizer }
];
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotc2FuaXRpemVyLnBpcGUuanMiLCJzb3VyY2VSb290IjoiL2hvbWUvdnN0cy93b3JrLzEvcy9jb21wb25lbnRzL3BpcGVzLyIsInNvdXJjZXMiOlsibnotc2FuaXRpemVyLnBpcGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUgsT0FBTyxFQUFFLElBQUksRUFBaUIsTUFBTSxlQUFlLENBQUM7QUFDcEQsT0FBTyxFQUFFLFlBQVksRUFBaUQsTUFBTSwyQkFBMkIsQ0FBQztBQVF4RyxNQUFNLE9BQU8sZUFBZTtJQUMxQixZQUFzQixTQUF1QjtRQUF2QixjQUFTLEdBQVQsU0FBUyxDQUFjO0lBQUcsQ0FBQztJQUtqRCxTQUFTLENBQUMsS0FBZ0IsRUFBRSxPQUF5QixNQUFNO1FBQ3pELFFBQVEsSUFBSSxFQUFFO1lBQ1osS0FBSyxNQUFNO2dCQUNULE9BQU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