Nativescript/angular2:没有applicationRef的提供者!部署后出现错误 [英] Nativescript/angular2: no provider for applicationRef! error after deployment
本文介绍了Nativescript/angular2:没有applicationRef的提供者!部署后出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行一个非常简单的nativescript/angular2应用,它似乎可以正常运行,但是在将该应用部署到android(genymotion)模拟器后,我收到了以下错误消息. 因此,似乎没有引导角度???完全不确定为什么会这样...知道我在做什么错吗?
i'm trying to run a very simple nativescript/angular2 app, it seems to build fine but after the app gets deployed to the android (genymotion) emulator I get the following error message. So it seems like angular isn't bootstrapped??? not sure at all why this is... Any idea what i'm doing wrong?
错误消息:
"@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文件是否有帮助:
My main.ts file if that helps:
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { AppModule } from "./app.module";
platformNativeScriptDynamic().bootstrapModule(AppModule);
和我的app.module.ts:
and my 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 {}
推荐答案
将BrowserModule导入app.module对我有用...
Importing the BrowserModule into app.module did it for me...
import { BrowserModule } from '@angular/platform-browser';
这篇关于Nativescript/angular2:没有applicationRef的提供者!部署后出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文