2016-10-19 71 views
3

我試圖在我現有的電子應用程序中運行非常基本的angular2東西。 Typescript文件被成功編譯成js代碼,電子運行正常。所有需要的文件都包含在index.html中。但是我在應用程序啓動時總是出現錯誤 - 沒有PlatformRef的提供程序!Electron應用程序中的Angular2錯誤:沒有PlatformRef的提供程序

No provider for PlatformRef!

我已經檢查此鏈接:No provider for PlatformRef error after upgrading to Angular2 RC5 in IE10

我沒有ES6-墊片的依賴,我的TS包的版本是2.0.3(最新)。

這是我的。

system.config.js

(function (global) { 
    System.config({ 
     paths: { 
      // paths serve as alias 
      'npm:': '../node_modules/' 
     }, 
     // map tells the System loader where to look for things 
     map: { 
      // our app is within the app folder 
      'app': 'app', 
      'main': 'app/main.bootstrap.js', 

      // angular bundles 
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 
      'rxjs': 'npm:rxjs', 
     }, 
     // packages tells the System loader how to load when no filename and/or no extension 
     packages: { 
      app: { 
       main: './main.bootstrap.js', 
       defaultExtension: 'js' 
      }, 
      rxjs: { 
       defaultExtension: 'js' 
      } 
     } 
    }); 
})(this); 

main.bootstrap.ts:

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

platformBrowserDynamic().bootstrapModule(AppModule); 

app.module.ts:

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

import {AppComponent} from './app.component'; 
import {DashboardComponent} from './dashboard.component'; 

import './rxjs-extensions'; 

@NgModule({ 
    imports: [ 
     BrowserModule, 
     FormsModule, 
     HttpModule, 
     RouterModule.forRoot([ 
      { 
       path: 'dashboard', 
       component: DashboardComponent 
      }, 
      { 
       path: '', 
       redirectTo: '/dashboard', 
       pathMatch: 'full' 
      } 
     ]) 
    ], 
    declarations: [ 
     AppComponent, 
     DashboardComponent 
    ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { 
} 

app.component.ts:

import { Component, OnInit } from '@angular/core'; 

@Component({ 
    selector: 'my-app', 
    template: '<h1>{{title}}</h1><div class="header-bar"></div>', 
    styleUrls: [''] 
}) 
export class AppComponent implements OnInit { 
    //component initialization 
    ngOnInit() { 
     //check authentication 
    } 

    title = 'Test'; 
} 

Index.jade:

doctype html 
html 
    head(lang="en") 
     meta(charset="UTF-8") 
     title 
     .... 
     script(type='text/javascript'). 
      System.import('systemjs.config.js').then(function() { 
       System.import('main'); 
      }).catch(console.error.bind(console)); 
    body 
     my-app 

非常感謝提前。

回答

1

我的問題是其中一個文件包含引用'q-io/fs'npm。只要我刪除這個用法,角就開始工作。很奇怪..

相關問題