Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 找不到管道:Angular 5自定义管道_Javascript_Angular_Iframe_Angular Pipe - Fatal编程技术网

Javascript 找不到管道:Angular 5自定义管道

Javascript 找不到管道:Angular 5自定义管道,javascript,angular,iframe,angular-pipe,Javascript,Angular,Iframe,Angular Pipe,我读过,也读过。我相信我已经完成了所有建议:将管道添加到共享的模块中 但是,无论我做什么,我都无法让我的模板找到我创建的管道。我的应用程序已经有一个共享模块,其他模块将导入该模块,因此我创建了管道并将其添加到共享模块中: 我用ngg pipe/shared/pipes/safe--flat--module shared--spec=false创建了它 在SharedModule中,我还将其添加到声明和提供者 一切都在运行,但我尝试使用管道,如: 我只是犯了个错误 错误:未捕获(承诺中):错误:

我读过,也读过。我相信我已经完成了所有建议:将管道添加到共享的模块中

但是,无论我做什么,我都无法让我的模板找到我创建的管道。我的应用程序已经有一个共享模块,其他模块将导入该模块,因此我创建了管道并将其添加到共享模块中:

我用
ngg pipe/shared/pipes/safe--flat--module shared--spec=false创建了它

在SharedModule中,我还将其添加到
声明
提供者

一切都在运行,但我尝试使用管道,如:

我只是犯了个错误

错误:未捕获(承诺中):错误:模板分析错误:无法找到管道“安全”

管道本身是

import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from '@angular/platform-browser';

@Pipe({
  name: 'safe'
})
export class SafePipe implements PipeTransform {

  constructor(protected sanitizer: DomSanitizer) { }

  public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
    switch (type) {
      case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
      case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
      case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
      case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
      case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
      default: throw new Error(`Invalid safe type specified: ${type}`);
    }
  }
}

您还需要将其添加到
SharedModule
导出下

exports: [
   SafePipe
]