Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.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
Typescript 有角度的2个全局管道,不带平台_管道_Typescript_Angular - Fatal编程技术网

Typescript 有角度的2个全局管道,不带平台_管道

Typescript 有角度的2个全局管道,不带平台_管道,typescript,angular,Typescript,Angular,我想使用此功能创建全局管道: 但这是不赞成的,它说: 不推荐通过提供程序提供平台管道。而是通过AppModule提供平台管道 文档确实不存在,以下是我需要制作成新版本的旧版本: import {PLATFORM_PIPES} from '@angular/core'; import {OtherPipe} from './myPipe'; @Component({ selector: 'my-component', template: ` {{123 | other-pipe}

我想使用此功能创建全局管道:

但这是不赞成的,它说: 不推荐通过提供程序提供平台管道。而是通过AppModule提供平台管道

文档确实不存在,以下是我需要制作成新版本的旧版本:

import {PLATFORM_PIPES} from '@angular/core';
import {OtherPipe} from './myPipe';
@Component({
  selector: 'my-component',
  template: `
    {{123 | other-pipe}}
  `
})
export class MyComponent {
  ...
}
bootstrap(MyComponent, [{provide: PLATFORM_PIPES, useValue: [OtherPipe], multi:true}]);

那么,有人知道如何将这个示例转换为使用AppModule的新版本吗?

AppModule是非常新的,最近做了很多更改(可能会在RC.5中出现)。我现在还是使用不推荐的方法

我还没有测试过,但类似的东西应该可以满足您的要求:

@AppModule({
  // modules: [MyModule],
  providers: [...]
  pipes: [OtherPipe]
})
class MyModule {}

bootstrap(AppCmp, {modules: [RouterModule, MyModule])