相关疑难解决方法(0)

如何在我的Karma/Jasmine测试中调试"[object ErrorEvent] thrown"错误?

我有几个失败的测试只输出[object ErrorEvent] thrown.我在控制台中看不到任何可以帮助我查明违规代码的内容.我需要做些什么来追踪这些?

[编辑]:我正在运行Karma v1.70,Jasmine v2.7.0

karma-jasmine angular-cli angular

104
推荐指数
5
解决办法
6万
查看次数

Angular 2无法在formArrays上找到具有未指定名称属性的控件

我试图迭代我的​​组件中的formArray但我得到以下错误

Error: Cannot find control with unspecified name attribute

这是我的类文件中的逻辑

export class AreasFormComponent implements OnInit {
    public initialState: any;
    public areasForm: FormGroup;

    constructor(private fb: FormBuilder) { }

    private area(): any {
      return this.fb.group({
          name: ['', [Validators.required]],
          latLong: ['', [Validators.required]],
          details: ['', [Validators.required]]
      });
    }

    public ngOnInit(): void {
        this.areasForm = this.fb.group({
            name: ['', [Validators.required]],
            areas: this.fb.array([this.area()])
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的模板文件

<form class="areas-form" [formGroup]="areasForm" (ngSubmit)="onSubmit(areasForm.values)">
    <md-input-container class="full-width">
        <input mdInput placeholder="Location Name" type="text" formControlName="name" required>
        <md-error *ngIf="areasForm.get('name').hasError('required')">Please enter the locationName</md-error>
    </md-input-container>
    <md-grid-list …
Run Code Online (Sandbox Code Playgroud)

loops angular2-forms angular

70
推荐指数
5
解决办法
9万
查看次数