我的angular2单元测试代码因下面的回溯而失败。我知道这是因为没有将formControlName
属性添加到FormGroup内的input
标记。
但我在该特定代码中添加了[ngModelOptions]="{standalone: true}"
。
<md-slide-toggle [(ngModel)]="isAvailable" color="primary" [ngModelOptions]="{standalone: true}">
</md-slide-toggle>
它在主站点中运行良好,但在测试时,它显示
PhantomJS 2.1.1 (Linux 0.0.0): Executed 39 of 65 (1 FAILED) (0 secs / 1.391 secs)
PhantomJS 2.1.1 (Linux 0.0.0) VehicleFormComponent should create FAILED
Error: Error in ./VehicleFormComponent class VehicleFormComponent - inline template:41:63 caused by: No value accessor for form control with unspecified name attribute in src/test.ts (line 98781)
_throwError@webpack:///~/@angular/forms/src/directives/shared.js:122:0 <- src/test.ts:15986:48