我正在关注Angular 2网站上的文档,使用upgradeAdapter来运行混合的Angular 2 / Angular 1应用程序,并且在实例化应用程序时遇到了一些麻烦。这是我在浏览器的控制台中看到的内容:
Failed to instantiate module NG2_UPGRADE_0_ due to:
Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module myApp.config due to:
配置和常量确实存在。这让我相信UpgradeAdapter没有正确升级Angular 1中编写的依赖项(或者我是否需要为所有Angular 1组件手动执行此操作?)
有什么遗失吗?
以下是我的app.ts中的内容:
import { UpgradeAdapter } from '@angular/upgrade';
const upgradeAdapter = new UpgradeAdapter();
(function () {
'use strict';
angular.module('myApp', [
//app dependencies
'myApp.config',
'myApp.constants',
//3rd party dependencies
'ngAnimate'
])
.config(config)
.run(run);
/*@ngInject*/
function config($httpProvider, $logProvider) {
}
/*@ngInject*/
function run() {
}
upgradeAdapter.bootstrap(document.body, ['myApp']);
})();
和vendor.ts:
import 'zone.js';
import 'reflect-metadata';
import 'angular';
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/common';
import '@angular/http';
import '@angular/router';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mergeMap';
我也使用Webpack作为模块加载器......虽然不确定它是否加载我的Angular 1模块......