首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有UpgradeModule的角6不能解析ApplicaitonModule的所有参数

带有UpgradeModule的角6不能解析ApplicaitonModule的所有参数
EN

Stack Overflow用户
提问于 2019-12-09 16:50:28
回答 1查看 344关注 0票数 0

我已经迁移了旧的AngularJS应用程序,使其在使用UpgradeModule的升级模式下以Range5运行。所有的东西都在工作,我有一些服务迁移到了services,并使用了一些更现代的lib,比如ngx翻译。一切都很顺利。然后,我按照更新指南更新到了角6。我修复了rxjs问题,所有导入都是正确的,但是当我统计应用程序时,我只是得到: Error:无法解决ApplicationModule:(?)的所有参数。在控制台里。

这是我的main.ts文件的模块部分:

代码语言:javascript
复制
import {NgModule} from '@angular/core';
import {HTTP_INTERCEPTORS} from '@angular/common/http';
import {HttpClientModule, HttpClient} from '@angular/common/http';
import {BrowserModule} from '@angular/platform-browser';
import {UpgradeModule} from '@angular/upgrade/static';
import { FormsModule } from '@angular/forms';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {ErrorHandler} from './components/error-interceptor/error.handler';
import {RequestInterceptor} from './components/error-interceptor/http-error-interceptor.service';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {httpLoaderFactory} from './http.loader.factory';
import {uiRouterStateProvider, uiRouterStateParamsProvider} from "./ajs-upgraded-providers";

import {RestService} from './components/rest/rest.service';
import {TemplateService} from './configuration/templates/template.service';
import {ValidationService} from './components/form-validation/form-validation.service';
import {AlertService} from './components/alert/alert.service';
import {UtilService} from './app.util.service';
import {AlertComponent} from './components/alert/alert.directive';
import {TemplateCreateComponent} from './configuration/templates/modify/template-create.controller';

@NgModule({
    imports: [
        BrowserModule,
        UpgradeModule,
        HttpClientModule,
        FormsModule,
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: httpLoaderFactory,
                deps: [HttpClient]
            }
        })
    ],
    providers: [
        RestService,
        ValidationService,
        AlertService,
        TemplateService,
        UtilService,
        uiRouterStateProvider,
        uiRouterStateParamsProvider,
        ErrorHandler,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: RequestInterceptor,
            multi: true,
        }
    ],
    declarations: [
      //solid angular components need only be entered here
        AlertComponent,
        TemplateCreateComponent
    ],
    entryComponents: [
      //add downgraded components here and in declarations
        AlertComponent,
        TemplateCreateComponent
    ]
})
export class AppModule {
    // Override Angular bootstrap so it doesn't do anything
    ngDoBootstrap() {
    }
}

// Bootstrap using the UpgradeModule
platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
    console.log("Bootstrapping in Hybrid mode with Angular & AngularJS");
    const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
    upgrade.bootstrap(document.body, ['PortalApp']);
});

这是package.json文件:

代码语言:javascript
复制
"dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/cli": "^6.2.9",
    "@angular/common": "^6.1.10",
    "@angular/compiler": "^6.1.10",
    "@angular/compiler-cli": "^6.1.10",
    "@angular/core": "^6.1.10",
    "@angular/forms": "^6.1.10",
    "@angular/http": "^6.1.10",
    "@angular/platform-browser": "^6.1.10",
    "@angular/platform-browser-dynamic": "^6.1.10",
    "@angular/platform-server": "^6.1.10",
    "@angular/router": "^6.1.10",
    "@angular/upgrade": "^6.1.10",
    "@ctrl/ngx-codemirror": "^1.3.10",
    "@ngx-translate/core": "^10.0.2",
    "@ngx-translate/http-loader": "^3.0.1",
    "angular": "~1.6.10",
    "angular-animate": "~1.6.10",
    "angular-breadcrumb": "~0.5.0",
    "angular-chosen-localytics": "~1.8.0",
    "angular-clipboard": "^1.5.0",
    "angular-cookies": "~1.6.10",
    "angular-in-memory-web-api": "~0.5.0",
    "angular-loading-bar": "~0.9.0",
    "angular-messages": "~1.6.10",
    "angular-moment-picker": "^0.10.2",
    "angular-sanitize": "~1.6.10",
    "angular-touch": "~1.6.10",
    "angular-translate": "~2.18.1",
    "angular-translate-loader-url": "~2.18.1",
    "angular-translate-storage-cookie": "~2.18.1",
    "angular-translate-storage-local": "~2.18.1",
    "angular-ui-grid": "~4.8.1",
    "angular-ui-router": "~1.0.22",
    "angular-ui-sortable": "0.14",
    "bootstrap": "^4.3.1",
    "chosen-js": "~1.8.7",
    "codemirror": "^5.49.2",
    "core-js": "^2.6.11",
    "jquery": "~2.2.4",
    "jquery-ui": "~1.12.1",
    "moment": "~2.24.0",
    "ng-csv": "~0.3.6",
    "ng-file-upload": "~12.2.13",
    "ng-ui-router-state-events": "^1.0.1",
    "popper.js": "^1.15.0",
    "rxjs": "6.0.0",
    "rxjs-compat": "6.2.2",
    "selectize": "~0.12.6",
    "tslint": "~5.0.0",
    "typescript": "~2.7.2",
    "typings": "^2.1.1",
    "ui-bootstrap4": "~3.0.6",
    "web-animations-js": "^2.3.1",
    "webpack-cli": "^3.3.9",
    "zone.js": "^0.8.4"
  }

我最后修正的是ngx翻译,它有一个不同的版本角5和6,但这已经更新,仍然是问题。知道是什么导致了这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-10 09:43:13

好的,经过大量的搜索,我在git轮毂的角度问题上遇到了一个帖子。我将链接它,因为它是完美的阅读,因为这个错误可能是由许多不同的问题。

对我来说,这是main.ts中指定的导入和提供程序的顺序,因此在这里:

代码语言:javascript
复制
providers: [
        uiRouterStateProvider,
        uiRouterStateParamsProvider,
        UtilService,
        RestService,
        ValidationService,
        AlertService,
        TemplateService
    ],
    declarations: [
      //solid angular components need only be entered here
        AlertComponent,
        TemplateCreateComponent
    ],
    entryComponents: [
      //add downgraded components here and in declarations
        AlertComponent,
        TemplateCreateComponent
    ]

例如,ValidationService和AlertService都引用了UtilService,但它们在导入中低于它们。在改变这一点之后,我的问题就解决了。

这是问题的链接,我认为这是有用的,因为这可以为未来的人们节省一天的搜索时间提供一个很好的参考。

角git轮毂问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59253293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档