Nativescript/angular2:没有 applicationRef 的提供者!部署后出错

Nativescript/angular2: no provider for applicationRef! error after deployment

我正在尝试 运行 一个非常简单的 nativescript/angular2 应用程序,它似乎可以正常构建,但是在将应用程序部署到 android (genymotion) 模拟器后,我得到了以下错误消息。 所以好像 angular 没有被引导???完全不确定这是为什么...知道我做错了什么吗?

错误信息:

"@angular/core": "2.1.2",
"@angular/forms": "2.1.2",
    "@angular/http": "2.1.2",
    "@angular/platform-browseBUILD SUCCESSFUL

Total time: 1 mins 39.836 secs
Project successfully built
Successfully deployed on device with identifier '192.168.8.101:5555'.
JS: ns-renderer: ERROR BOOTSTRAPPING ANGULAR
JS: ns-renderer: No provider for ApplicationRef!
JS:
JS: Error: No provider for ApplicationRef!
JS:     at NoProviderError.Error (native)
JS:     at NoProviderError.BaseError [as constructor] (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:1104:38)
JS:     at NoProviderError.AbstractProviderError [as constructor] (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:1235:20)
JS:     at new NoProviderError (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:1266:20)
JS:     at ReflectiveInjector_._throwOrNull (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2906:23)
JS:     at ReflectiveInjector_._getByKeyDefault (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2934:29)
JS:     at ReflectiveInjector_._getByKey (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2897:29)
JS:     at ReflectiveInjector_.get (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/core/bundles/core.umd.js:2706:25)
JS:     at NgModuleInjector.Object.defineProperty.get (/AppModule/module.ngfactory.js:58:87)
JS:     at NgModuleInjector.AppModuleInjector.createInternal (/AppModule/module.ngfactory.js:83:60)

我的 main.ts 文件如果有帮助的话:

import { platformNativeScriptDynamic } from "nativescript-angular/platform";


import { AppModule } from "./app.module";



platformNativeScriptDynamic().bootstrapModule(AppModule);

和我的 app.module.ts:

import { NgModule } from "@angular/core";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NativeScriptModule } from "nativescript-angular/platform";
import { NativeScriptRouterModule } from "nativescript-angular/router";

import { AppComponent } from "./app.component";
import {routes, navigatableComponents } from "./app.routing";

@NgModule({
    imports : [(
    NativeScriptModule, NativeScriptFormsModule, NativeScriptRouterModule, NativeScriptRouterModule.forRoot(routes)
    )],
    declarations : [AppComponent, ...navigatableComponents
    ],
    bootstrap : [AppComponent]      
})
export class AppModule {}

去掉ngModule中你的imports的括号,它应该是一个模块数组。像这样:

@NgModule({
    imports : [
    NativeScriptModule, NativeScriptFormsModule,    NativeScriptRouterModule, NativeScriptRouterModule.forRoot(routes)
    ],
    declarations : [AppComponent, ...navigatableComponents ],
    bootstrap : [AppComponent]      
})

将 BrowserModule 导入 app.module 对我来说...

import { BrowserModule } from '@angular/platform-browser';