Typescript 有角度的2个全局管道,不带平台_管道
我想使用此功能创建全局管道: 但这是不赞成的,它说: 不推荐通过提供程序提供平台管道。而是通过AppModule提供平台管道 文档确实不存在,以下是我需要制作成新版本的旧版本: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}
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])