Angular 2.0.0-rc.2:如何迁移PLATFORM_DIRECTIVES [英] Angular 2.0.0-rc.2: How to migrate PLATFORM_DIRECTIVES
问题描述
位于 https://github.com/angular/angular/blob的更改日志/master/CHANGELOG.md 提到:
PLATFORM_PIPES和PLATFORM_DIRECTIVES现在是 编译器配置.除了提供对这些令牌的绑定以外, 为CompilerConfig提供绑定.
PLATFORM_PIPES and PLATFORM_DIRECTIVES now are fields on CompilerConfig. Instead of providing a binding to these tokens, provide a binding for CompilerConfig instead.
到目前为止,我的引导文件中包含以下行:
So far I have these lines in my bootstrap file:
bootstrap(
AppComponent,
[...
provide(PLATFORM_DIRECTIVES, {useValue: ROUTER_DIRECTIVES, multi: true}),
...]);
我应该如何更改provide()函数?任何提示表示赞赏.
How should I change the function provide()? Any hint is appreciated.
推荐答案
我从此处使用 disableDeprecatedForms()方法作为指南:
I used the disableDeprecatedForms() method from here as a guide: https://github.com/angular/angular/blob/master/modules/@angular/forms/src/form_providers.ts
因此您的代码应类似于:
So your code should look something like:
bootstrap(
AppComponent,
[...
provide(CompilerConfig, {
useFactory: (platformDirectives: any[], platformPipes: any[]) => {
return new CompilerConfig({
platformDirectives: platformDirectives.concat(...ROUTER_DIRECTIVES),
platformPipes: platformPipes
});
},
deps: [PLATFORM_DIRECTIVES, PLATFORM_PIPES]}),
...]);
这篇关于Angular 2.0.0-rc.2:如何迁移PLATFORM_DIRECTIVES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!