在IE10中升级到Angular2 RC5后,没有提供PlatformRef错误的提供程序 [英] No provider for PlatformRef error after upgrading to Angular2 RC5 in IE10

查看:97
本文介绍了在IE10中升级到Angular2 RC5后,没有提供PlatformRef错误的提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到Angular2 RC5.该应用程序在所有浏览器中均可正常加载,但IE10除外.我收到一个异常没有PlatformRef的提供者!"当我引导应用程序时.在RC4中一切正常.我在网上看到一些有关此异常的帖子,但它们都与Meteor有关.我不使用流星.我的项目源自AngularSeed(我手动更新为RC5的先前版本).关于如何解决这个问题的任何想法?谢谢!

I just upgraded to Angular2 RC5. The app loads fine in all browsers exception IE10. I get an exception "No provider for PlatformRef!" when I bootstrap the application. Everything worked fine in RC4. I saw some posts on the web about this exception, but they were all related to Meteor. I do not use meteor. My project is derived from AngularSeed (previous version that I updated manually to RC5). Any idea on how to fix this? Thanks!

在IE10中,出现此错误:

In IE10, I get this error:

No provider for PlatformRef!  
{
  [functions]: ,
  context: <Permission denied>,
  injectors: [ ],
  keys: [ ],
  message: "No provider for PlatformRef!",
  name: "Error",
  stack: undefined,
  Symbol()_m.sovohbnexgu: undefined,
  Symbol()_n.sovohbnexgu: undefined,
  Symbol()_o.sovohbnexgu: undefined,
  Symbol(rxSubscriber)_p.sovohbnexgu: undefined
}

main.ts:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule }              from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

AppModule:

AppModule:

import { provide, NgModule, ExceptionHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './components/app/app.component';
import { AppExceptionHandler } from './app.exceptionhandler';
import { AppRoutes } from './app.routes';
import { LogService, ... } from './services/';

@NgModule({
    declarations: [AppComponent, ...],
    imports: [BrowserModule,
              RouterModule.forRoot(AppRoutes),
              HttpModule,
              FormsModule],
    providers: [provide(ExceptionHandler, { useClass: AppExceptionHandler }), LogService, ...],
    bootstrap: [AppComponent],
})
export class AppModule { }

依赖版本:

  • "@ angular/common":"2.0.0-rc.5",
  • "@ angular/compiler":"2.0.0-rc.5",
  • "@ angular/core":"2.0.0-rc.5",
  • "@ angular/forms":"0.3.0",
  • "@ angular/http":"2.0.0-rc.5",
  • "@ angular/platform-b​​rowser":"2.0.0-rc.5",
  • "@ angular/platform-b​​rowser-dynamic":"2.0.0-rc.5",
  • "@ angular/路由器":"3.0.0-rc.1",
  • "es6-module-loader":"^ 0.17.8",
  • "core-js":"^ 2.4.0",
  • "rxjs":"5.0.0-beta.6",
  • "systemjs":"0.19.27",
  • "zone.js":"0.6.13",
  • "@angular/common": "2.0.0-rc.5",
  • "@angular/compiler": "2.0.0-rc.5",
  • "@angular/core": "2.0.0-rc.5",
  • "@angular/forms": "0.3.0",
  • "@angular/http": "2.0.0-rc.5",
  • "@angular/platform-browser": "2.0.0-rc.5",
  • "@angular/platform-browser-dynamic": "2.0.0-rc.5",
  • "@angular/router": "3.0.0-rc.1",
  • "es6-module-loader": "^0.17.8",
  • "core-js": "^2.4.0",
  • "rxjs": "5.0.0-beta.6",
  • "systemjs": "0.19.27",
  • "zone.js": "0.6.13",

如果我尝试将PlatformRef添加到@NgModule导入中,则会出现此错误:

If I try to add PlatformRef to the @NgModule imports, I get this error:

shims.js?1472473326356:4 Uncaught TypeError: Cannot read property 'type' of null(anonymous function) 
@ app.js?1472473326358:5getTransitiveModules 
@ app.js?1472473326358:5CompileMetadataResolver._getTransitiveNgModuleMetadata 
@ app.js?1472473326358:5CompileMetadataResolver.getNgModuleMetadata 
@ app.js?1472473326358:5RuntimeCompiler._compileComponents 
@ app.js?1472473326358:3RuntimeCompiler._compileModuleAndComponents 
@ app.js?1472473326358:3RuntimeCompiler.compileModuleAsync 
@ app.js?1472473326358:3PlatformRef_._bootstrapModuleWithZone 
@ app.js?1472473326358:48PlatformRef_.bootstrapModule 
@ app.js?1472473326358:48bootstrapper 
@ app.js?1472473326358:57(anonymous function) 
[...]

我在IE上获得了这个堆栈:

I get this stack on IE:

"TypeError: Unable to get property 'type' of undefined or null reference
   at Anonymous function (eval code:13673:13)
   at Call (http://localhost:5555/node_modules/es6-shim/es6-shim.js?1472473192889:289:7)
   at forEach (http://localhost:5555/node_modules/es6-shim/es6-shim.js?1472473192889:1295:7)
   at getTransitiveModules (eval code:13672:9)
   at CompileMetadataResolver.prototype._getTransitiveNgModuleMetadata (eval code:13387:13)
   at CompileMetadataResolver.prototype.getNgModuleMetadata (eval code:13259:17)
   at RuntimeCompiler.prototype._compileComponents (eval code:15845:13)
   at RuntimeCompiler.prototype._compileModuleAndComponents (eval code:15769:13)
   at RuntimeCompiler.prototype.compileModuleAsync (eval code:15746:13)
   at PlatformRef_.prototype._bootstrapModuleWithZone (eval code:9991:13)"

推荐答案

解决方案是从依赖项中删除es6-shim.现在可以正常工作.

The solution was to remove es6-shim from the dependencies. Works fine now.

这篇关于在IE10中升级到Angular2 RC5后,没有提供PlatformRef错误的提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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