在构造函数中添加表单构建器时。我一直收到错误。我已经在 app.module 中添加了 ReactiveFormsModule 。

import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
@Component({
    selector: 'app',
    template: require('./app.component.pug'),
    styles: [require('./app.component.scss')]
})
export class AppComponent {
    private loginForm: FormGroup;
    constructor(private fb: FormBuilder) {}
}

示例 app.module.ts
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
    imports: [BrowserModule, ReactiveFormsModule],
    declarations: [AppComponent],
    providers: [],
    bootstrap: [AppComponent]
})

这是错误:

javascript - 未捕获的错误 : Can't resolve all parameters for AppComponent: (? )-LMLPHP

最佳答案

emitDecoratorMetadata: true 添加到 tsconfig.json 文件

关于javascript - 未捕获的错误 : Can't resolve all parameters for AppComponent: (? ),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49773066/

10-10 11:09