使用 UpgradeModule 从 AngularJS 1.5 升级到 Angular 5 时出错 [英] Error when using UpgradeModule upgrading from AngularJS 1.5 to Angular 5

查看:49
本文介绍了使用 UpgradeModule 从 AngularJS 1.5 升级到 Angular 5 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在遵循 Angular 升级指南来创建一个混合的 AngularJS/Angular 应用程序,但我在第一个障碍上失败了.

I've been following the Angular upgrade guide to create a hybrid AngularJS/Angular app, but I'm falling at the first hurdle.

我收到以下错误:

未捕获的错误:无法解析 AppModule 的所有参数:(?).

这是我的 app.module.ts 文件:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

@NgModule({
    imports: [
        BrowserModule,
        UpgradeModule
    ]
})

export class AppModule {
    constructor(private upgrade: UpgradeModule) {}

    ngDoBootstrap() {
        this.upgrade.bootstrap(document.body, ['MyApp'], { strictDi: true });
    }
}

platformBrowserDynamic().bootstrapModule(AppModule);

值得指出的是,我正在使用 webpack,并且我尝试将 @angular/upgrade/static 包别名如下:

It's worth pointing out that I'm using webpack, and I've tried aliasing the @angular/upgrade/static package as follows:

resolve: {
    extensions: ['.ts', '.js'],
    alias: {
        "@angular/upgrade/static": "@angular/upgrade/bundles/upgrade-static.umd.js"
    }
},

但这似乎根本没有帮助.

But this doesn't seem to help at all.

知道这里发生了什么吗?

Any ideas what's going on here?

推荐答案

我通过 这篇文章,并调整我的 tsconfig 以匹配 angular-cli 生成的配置.

I managed to figure this out through a combination of this article, and tweaking my tsconfig to match one generated by angular-cli.

这篇关于使用 UpgradeModule 从 AngularJS 1.5 升级到 Angular 5 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆