angular – 无法解析app模块的参数

前端之家收集整理的这篇文章主要介绍了angular – 无法解析app模块的参数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用角度为1.6和5的混合应用程序.手动引导有效.一旦我尝试引导混合应用程序,我就会收到以下错误

compiler.js?7e34:466 Uncaught Error: Can’t resolve all parameters for
AppModule: (?).
at SyntaxError (eval at (app.bundle.js:1852),:684:34)
at CompileMetadataResolver._getDependenciesMetadata (eval at (app.bundle.js:1852),:15765:35)
at CompileMetadataResolver._getTypeMetadata (eval at (app.bundle.js:1852),:15600:26)
at CompileMetadataResolver.getNgModuleMetadata (eval at (app.bundle.js:1852),:15399:24)
at JitCompiler._loadModules (eval at (app.bundle.js:1852),:33760:87)
at JitCompiler._compileModuleAndComponents (eval at (app.bundle.js:1852),:33721:36)
at JitCompiler.compileModuleAsync (eval at (app.bundle.js:1852),:33637:37)
at CompilerImpl.compileModuleAsync (eval at (app.bundle.js:1864),:245:49)
at PlatformRef.bootstrapModule (eval at (app.bundle.js:229),:5646:25)
at eval (eval at (app.bundle.js:827),:76:53)

app.ts

.platformBrowserDynamic()bootstrapModule(的AppModule);

app.module.ts

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {UpgradeModule} from '@angular/upgrade/static';

@NgModule({
    imports: [
        BrowserModule,UpgradeModule
    ]
})
export class AppModule {
    constructor(private upgrade: UpgradeModule) {
    }

    ngDoBootstrap() {
        this.upgrade.bootstrap(document.documentElement,['myApp']);
    }
}

tsconfig.json

{
  "compileOnSave": false,"compilerOptions": {
    "outDir": "./dist/out-tsc","sourceMap": true,"declaration": false,"module": "commonjs","emitDecoratorMetadata": true,"experimentalDecorators": true,"target": "es5","typeRoots": [
      "node_modules/@types"
    ],"lib": [
      "es2017","dom"
    ]
  }
}

我正在使用webpack.这是我配置的一部分:

resolve: {
    extensions: ['.js','.ts'],alias: {
        "@angular/upgrade/static": "@angular/upgrade/bundles/upgrade-static.umd.js"
    }
},module: {
    rules: [
        {
            test: /\.ts$/,loader: 'ts-loader',exclude: '/node_modules'
        },
就你所分享代码而言,一切似乎都是有序的.但是,你可能正在使用另一个与Angular的装饰器发生冲突的注释库.例如,如果你使用 angular-ts-decorators肯定会导致这样的问题.

如果是这种情况 – 删除其他注释库(现在应该是冗余的)并使用Angular的注释.

原文链接:https://www.f2er.com/angularjs/142038.html

猜你在找的Angularjs相关文章