2

我刚升级到Angular2 RC5。该应用程序加载罚款在所有浏览器例外IE10。我收到一个异常“没有PlatformRef的提供者!”当我引导应用程序。在RC4中一切正常。我在网上看到一些关于这个例外的帖子,但他们都与流星有关。我不使用流星。我的项目来自AngularSeed(以前版本,我手动更新为RC5)。任何想法如何解决这个问题?谢谢!在IE10中升级到Angular2 RC5后没有PlatformRef错误提供程序

在IE10中,我得到这个错误:

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:

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.0-rc.5"
  • “@角/形式”: “0.3.0”,
  • “@角/ 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/router“: “3.0.0-rc.1”,
  • “es6-module-loader”:“^ 0.17.8" ,
  • “核心-JS”: “^ 2.4.0”,
  • “rxjs”: “5.0.0-beta.6”
  • “systemjs”: “0.19.27” ,
  • “zone.js”: “0.6.13”,

编辑:如果我尝试PlatformRef添加到@NgModule进口,我得到这个错误:

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:

"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)" 

回答

0

解决方案是从依赖关系中删除es6-shim。现在工作正常。

+1

没有polyfills,它表示没有Object.assign方法。 – kirilloid

+1

解决了这个问题吗? 我也面临同样的问题,并且在移除es6-shim后没有解决。 – Sanjeev

+2

是的,据我所知,去除es6垫片根本不起作用。 IE仍然不支持Object.assign。 – Robert

0

我想你应该从@angular/core进口PlatformRef并将其添加到的NgModuleimports配置为您的AppModule文件后检查相同。

+0

我试过了,但我现在得到一个错误:“TypeError:无法读取null属性'type' – maxim1500

+0

我也尝试将它添加到模块上的提供者列表中,并且它不能解决问题。 – maxim1500

+0

“TypeError:无法读取'null'属性'error'错误?也提供'@ angular/core'已过时,因此您必须将Appmodule中的'ExceptionHandler'提供程序设置更改为'{provide:ExceptionHandler,useClass :AppExceptionHandler}' – ranakrunal9

相关问题