0
我有称为DataService的SharedService。我试图把它作为Singleton。 于是,我就当我运行来引导这在我app.module.ts这样Bootstraping全局服务的问题
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/platform";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NativeScriptHttpModule } from "nativescript-angular/http";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import "reflect-metadata";
import { AppComponent } from "./app.component";
import {ArraysPipe} from "./arraypipe";
import { routes, navigatableComponents } from "./app.routing";
import { DataService } from "./services/passenger-list.services";
@NgModule({
declarations: [AppComponent,ArraysPipe,...navigatableComponents],
//providers:[DataService],
bootstrap: [AppComponent,[DataService]],
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes)
],
schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule { }
,它扔我异常
组件的DataService没有任何NgModule的部分或模块尚未导入你的模块。
请帮忙!!!!
[角2分量的可能的复制是不部分任何NgModule](http://stackoverflow.com/questions/39527722/angular-2-component-is-not-part-of-any-ngmodule) –
它不重复 –
请按照以下步骤提供的Yakov Fain同时,你可以看看这个例子来看看如何使用你se服务作为提供者https://github.com/NativeScript/nativescript-sdk-examples-ng/blob/d978f0beae3f16198f57be2fbd4138cd35cd2d51/app/http/http-post/http-post.component.ts#L8 –