【问题标题】:Angular 2.0.0-rc.2: How to migrate PLATFORM_DIRECTIVESAngular 2.0.0-rc.2:如何迁移 PLATFORM_DIRECTIVES
【发布时间】:2016-06-18 12:34:10
【问题描述】:

https://github.com/angular/angular/blob/master/CHANGELOG.md 的更新日志提到:

PLATFORM_PIPES 和 PLATFORM_DIRECTIVES 现在是 编译器配置。而不是提供对这些令牌的绑定, 而是为 CompilerConfig 提供一个绑定。

到目前为止,我的引导文件中有这些行:

bootstrap(
    AppComponent,
    [...
        provide(PLATFORM_DIRECTIVES, {useValue: ROUTER_DIRECTIVES, multi: true}),
    ...]);

我应该如何更改函数provide()?任何提示表示赞赏。

【问题讨论】:

    标签: angular


    【解决方案1】:

    我使用此处的 disableDeprecatedForms() 方法作为指导:https://github.com/angular/angular/blob/master/modules/@angular/forms/src/form_providers.ts

    所以你的代码应该是这样的:

        bootstrap(
    AppComponent,
    [...
        provide(CompilerConfig, {
            useFactory: (platformDirectives: any[], platformPipes: any[]) => {
                return new CompilerConfig({
                    platformDirectives: platformDirectives.concat(...ROUTER_DIRECTIVES),
                    platformPipes: platformPipes
                });
            },
            deps: [PLATFORM_DIRECTIVES, PLATFORM_PIPES]}),
    ...]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-18
      • 2016-09-02
      • 1970-01-01
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多