Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Electron应用程序中的Angular2错误:PlatformRef没有提供程序_Javascript_Angular_Typescript_Gulp_Electron - Fatal编程技术网

Javascript Electron应用程序中的Angular2错误:PlatformRef没有提供程序

Javascript Electron应用程序中的Angular2错误:PlatformRef没有提供程序,javascript,angular,typescript,gulp,electron,Javascript,Angular,Typescript,Gulp,Electron,我正在尝试在我现有的电子应用程序中运行非常基本的angular2。 Typescript文件已成功编译成js代码,electron运行良好。所有需要的文件都包含在index.html中。但我在应用程序启动时总是出错-PlatformRef没有提供程序 我已经检查了此链接: 我没有es6垫片依赖关系,我的TS包版本是2.0.3(最新版本) 这是我的 system.config.js (function (global) { System.config({ paths: {

我正在尝试在我现有的电子应用程序中运行非常基本的angular2。 Typescript文件已成功编译成js代码,electron运行良好。所有需要的文件都包含在index.html中。但我在应用程序启动时总是出错-PlatformRef没有提供程序

我已经检查了此链接:

我没有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';
}

非常感谢。

我的问题是其中一个文件包含对“q-io/fs”npm的引用。我一去掉这个用法,angular就开始工作了。很奇怪

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