我已经升级/混合AngularJS /角2应用程序,我得到这个错误:角:无法添加属性resumeBootstrap,对象是不可扩展
Unhandled Promise rejection: Cannot add property resumeBootstrap, object is not extensible ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot add property resumeBootstrap, object is not extensible at UpgradeModule.bootstrap (upgrade_module.ts:259)
在该位置的源代码是:
// Make sure resumeBootstrap() only exists if the current bootstrap is deferred
const windowAngular = (window as any)['angular'];
windowAngular.resumeBootstrap = undefined;
我的代码工作正常。引入最新的Angular变化似乎导致了这一点。
这里是我的启动代码:
import {platformBrowser} from '@angular/platform-browser';
import {UpgradeModule} from '@angular/upgrade/static';
import {AppModuleNgFactory} from './app_module.ngfactory';
angular.element(document.body).ready(() => {
platformBrowser()
.bootstrapModuleFactory(AppModuleNgFactory)
.then(platformRef => {
const upgrade =
platformRef.injector.get(UpgradeModule) as UpgradeModule;
// This is the line that fails:
upgrade.bootstrap(document.body, ['foo-obfuscated'], {strictDi: false});
});
更新:我想在我的AppModule
移动upgrade.bootstrap
调用ngDoBootstrap
像角升级文档例子,但这并没有改变任何东西。
是什么zone.js –
zone.js版本的版本是0.8.12 –