当前位置: 首页 > 知识库问答 >
问题:

无法解析[...]的所有参数

计燕七
2023-03-14
  • @可在Service1和service2中注入
  • tsconfig.json emitDecoratorMetadata设置为true
  • 在NGModule的提供者部分注册了Service1和Service2

如果有关系的话:我正在构建一个Ionic2RC0应用程序。以下是重要的文件:

app.module.ts

import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import {AppConfig} from "../config/app-config";
import {ConnectionService} from "../services/ilias-app.service";
import {ILIASRestProvider} from "../providers/ilias-rest.provider";
import {MigrationsService} from "../services/migrations.service";
import {FooterToolbarService} from "../services/footer-toolbar.service";
import {ObjectListPage} from "../pages/object-list/object-list";
import {FavoritesPage} from "../pages/favorites/favorites";
import {NewObjectsPage} from "../pages/new-objects/new-objects";
import {SettingsPage} from "../pages/settings/settings";
import {InfoPage} from "../pages/info/info";
import {LogoutPage} from "../pages/logout/logout";
import {SynchronizationService} from "../services/synchronization.service";
import {DataProvider} from "../providers/data-provider.provider";
import {FileService} from "../services/file.service";
import {DataProviderFileObjectHandler} from "../providers/handlers/file-object-handler";
import {TranslatePipe} from "ionic-angular/index";
import {FileSizePipe} from "../pipes/fileSize.pipe";
import {HttpModule, Http} from '@angular/http';
import {TranslateModule} from 'ng2-translate/ng2-translate';
import {TranslateLoader} from "ng2-translate/src/translate.service";
import {TranslateStaticLoader} from "ng2-translate/src/translate.service";

@NgModule({
  declarations: [
    MyApp,
    ObjectListPage,
    FavoritesPage,
    NewObjectsPage,
    SettingsPage,
    InfoPage,
    LogoutPage,
    FileSizePipe,
    TranslatePipe
  ],
  imports: [
    HttpModule,
    IonicModule.forRoot(MyApp, {prodMode: window.hasOwnProperty('cordova')}),
    TranslateModule.forRoot({
      provide: TranslateLoader,
      useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
      deps: [Http]
    })
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    ObjectListPage,
    FavoritesPage,
    NewObjectsPage,
    SettingsPage,
    InfoPage,
    LogoutPage
  ],
  providers: [
    AppConfig,
    ConnectionService, //<-----------------------
    MigrationsService,
    ILIASRestProvider, //<-------------------------
    FooterToolbarService,
    DataProvider,
    FileService,
    SynchronizationService,
    DataProviderFileObjectHandler
  ]
})
export class AppModule {}
@Injectable()
export class ILIASRestProvider {

    public constructor(private http:Http, public app:ConnectionService) {
    }
    ...
}
@Injectable()
export class ConnectionService {

    ...

    constructor(public _config:AppConfig) {
        this._database = SQLiteDatabaseService.instance();
    }

    ...
}
@Injectable()
export class AppConfig {

    protected data:any = {};

    constructor(public http:Http) {
    }

    ...
}
Your system information:

Cordova CLI: 5.4.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS 
Node Version: v6.6.0

共有1个答案

郗奇玮
2023-03-14

我建议的第一件事是直接从文件中导入,而不是从桶中导入,因为这是理想的方式。

import {HttpModule, Http} from '@angular/http'; 
import {ConnectionService} from "../services/ilias-app.service";

@Injectable()
export class ILIASRestProvider {

public constructor(private http:Http, public app:ConnectionService) {
}
...
}

其次,如果上述解决方案在您的项目中是不可能的,那么请重新排序import语句。它们的顺序不对。例如,http正在ILIASRestProvider中使用,应该在ILIASRestProvider之前导入。

希望这能有所帮助

 类似资料: