小编Anh*_*Ngo的帖子

茉莉花-无法读取未定义的属性“控件”-Angular 6

我是Angular的初学者,正在Jasmine中为Angular6编写测试EmployeeComponent。我有一个错误

无法读取未定义的属性“控件”

我想我没有在employee.component.spec.ts文件中正确设置所有依赖项。我研究了几天,但没有结果。任何帮助将非常感激。

这是我代码中的基本流程。员工部分包含注册表。当用户单击时Submit,员工服务将向Firebase插入/更新数据。

以下是employee.component.html

 <div class="row">
  <div class="col-md-5">
    <form [formGroup]="this.employeeService.form" (ngSubmit)="onSubmit()">
      <input type="hidden" formControlName="$key">
      <div class="form-group" *ngIf="page1">
        <label>Full Name</label>
        <input formControlName="fullName" class="form-control" [ngClass]="{'is-invalid': submitted && formControls.fullName.errors}">
        <div class="invalid-feedback" *ngIf="submitted && formControls.fullName.errors">
          This field is required.
        </div>
      </div>

      <div class="form-group" *ngIf="page1">
        <label>Email</label>
        <input formControlName="email" class="form-control" [ngClass]="{'is-invalid': submitted && formControls.email.errors}">
        <div class="invalid-feedback" *ngIf="submitted && formControls.email.errors">
            Invalid Email Address.
          </div>
      </div>

      <div class="form-group" *ngIf="page1">
        <label>Mobile</label>
        <input formControlName="mobile" class="form-control" [ngClass]="{'is-invalid': submitted && formControls.mobile.errors}">
        <div class="invalid-feedback" *ngIf="submitted && …
Run Code Online (Sandbox Code Playgroud)

testing jasmine karma-runner angular angular-reactive-forms

5
推荐指数
1
解决办法
2983
查看次数