angle2ユニットのテストコードが以下のトレースバックで失敗します。 FormGroup内にあるinput
タグにformControlName
属性を追加していないためです。[ngModelOptions] = "{standalone:true}"の角度単位テストに失敗しました
しかし、その特定のタグに[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)
[email protected]:///~/@angular/forms/src/directives/shared.js:122:0 <- src/test.ts:15986:48
ので、それは私の意見では非常に現実的な選択肢である、どのような方法で、あなたのコードの実行を変更しません[ (ngModel)] = "isAvailable" color = "primary" name = "isAvaialble"> 'それはisAvaiableという名前に関連付けられたフォームコントロールなしのように表示されます。最後に、 '[ngModelOptions] =" {standalone:true} "を' ngDefaultControl'に置き換えて動作させます。 –
あなたがそれを理解したことは間違いありません! :) – Alex