4
我有一個運行AngularJS 1.5的應用程序,我嘗試使用NgUpgrade開始將舊組件遷移到Angular。AngularJS to Angular - NgUpgrade
我的第一步是讓兩個框架並排運行。但是,使用NgUpgrade的時候,我發現了以下錯誤:
Unhandled Promise rejection: [$injector:modulerr] Failed to instantiate module $$UpgradeModule due to:
Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module undefined due to:
Error: [ng:areq] Argument 'module' is not a function, got undefined
基本上我有角爲AngularJS的app.module.ts和app.js。
遵循角度文檔,我創建了一個main.ts來引導這兩個框架。
import { AppModule } from './app.module';
import { UpgradeModule } from '@angular/upgrade/static';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
console.log('Bootstrap both Angular and AngularJS ');
const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
upgrade.bootstrap(document.body, ['myApp'], {strictDi: true});
});
For creating my bundle, I'm using webpack.
你有沒有發現這個錯誤就任何決議案? –
請參閱下面的文章。這是我們AppModule的當前狀態。工作沒有問題。 – Nocktu