在浏览器控制台中获取以下异常。
EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: No provider for PlatformLocation!
ORIGINAL STACKTRACE:
Error: DI Exception
at NoProviderError.BaseException [as constructor] (http://localhost:3000/lib/@angular/core/core.umd.js:3776:27)
at NoProviderError.AbstractProviderError [as constructor] (http://localhost:3000/lib/@angular/core/core.umd.js:4307:20)
at new NoProviderError (http://localhost:3000/lib/@angular/core/core.umd.js:4342:20)
at ReflectiveInjector_._throwOrNull (http://localhost:3000/lib/@angular/core/core.umd.js:5794:23)
at ReflectiveInjector_._getByKeyDefault (http://localhost:3000/lib/@angular/core/core.umd.js:5822:29)
at ReflectiveInjector_._getByKey (http://localhost:3000/lib/@angular/core/core.umd.js:5785:29)
at ReflectiveInjector_.get (http://localhost:3000/lib/@angular/core/core.umd.js:5594:25)
at _View_WalletPlus_Host0.createInternal (WalletPlus_Host.template.js:38:83)
at _View_WalletPlus_Host0.AppView.create (http://localhost:3000/lib/@angular/core/core.umd.js:9862:25)
at _View_WalletPlus_Host0.DebugAppView.create (http://localhost:3000/lib/@angular/core/core.umd.js:10054:48)
ERROR CONTEXT:
[object Object]
请帮忙解决此问题。不明白究竟是什么问题。
下面是index.ts,我在引导我的应用程序。
import {bootstrap} from "@angular/platform-browser-dynamic";
import {enableProdMode,provide} from "@angular/core";
import {ROUTER_PROVIDERS} from "@angular/router";
import {HTTP_PROVIDERS} from "@angular/http";
import {MyAppComponent} from "./components/MyApp.component";
import {SimpleExpiry} from 'ng2-idle/simpleexpiry';
import {APP_BASE_HREF, LocationStrategy, HashLocationStrategy} from "@angular/common";
enableProdMode();
bootstrap(<any>MyAppComponent, [ROUTER_PROVIDERS, HTTP_PROVIDERS,SimpleExpiry,
provide(APP_BASE_HREF, { useValue: "/" }),
provide(LocationStrategy, { useClass: HashLocationStrategy })]);
答案 0 :(得分:0)
您必须在 NativeScriptRouterModule
内输入main.ts文件中的内容。
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
@NgModule({
declarations: [
AppComponent,
routableComponents,
],
bootstrap: [AppComponent],
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes),
],
})