错误:无法解析ApplicationModule的所有参数:(?) [英] Error: Can't resolve all parameters for ApplicationModule: (?)

查看:59
本文介绍了错误:无法解析ApplicationModule的所有参数:(?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建不带CLI的Angular应用程序. 之后,我得到一个错误:

I want to create Angular application without CLI. After that I get an error:

错误:无法解析ApplicationModule的所有参数:(?).

项目包含几个文件,主要是:

Project contains couple files, main of this is:

•main.ts

import 'zone.js/dist/zone'
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './modules/app.module';

platformBrowserDynamic().bootstrapModule(AppModule)

•component.ts

• component.ts

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `Hello World`
})
export class AppComponent {}

•module.ts

• module.ts

import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { AppComponent } from "../components/app.component";

@NgModule({
    imports: [
        BrowserModule,
    ],
    declarations: [
        AppComponent
    ],
    bootstrap: [
        AppComponent
    ]
})
export class AppModule {}

我之前在StackOverflow上进行搜索,但是找不到解决方案. 当有人想在没有@Injectable装饰器的情况下注入服务时,会发生类似的错误.就我而言,我没有任何服务,因此恐怕没有人会遇到相同的错误.

I search on StackOverflow before, but I can't found solution. Similar error occur when someone wants to inject service without @Injectable decorator. In my case I don't have any service, so that am afraid nobody has the same error.

Angular CLI非常容易启动项目,但是只有当您想要不使用生成器来安装项目时,您才知道在引导应用程序中需要创建哪些部分.

Angular CLI is so simple to start project, but only when you want setup project without generator, you know what parts are necessary to create during bootstrap application.

推荐答案

  1. 通过命令安装core-js:

  1. Install core-js by command:

npm i core-js

  • 添加main.ts文件:

    import 'core-js/es6/reflect';
    import 'core-js/es7/reflect';
    

  • 顺便说一句.我花了一整天的时间来解决这个问题.

    这篇关于错误:无法解析ApplicationModule的所有参数:(?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆