Coding⏱️ 2 min read📅 2026-05-31

How to Fix: ERROR Error: No value accessor for form control with unspecified name attribute on switch

Quick Answer: The error is caused by the missing name attribute in the switch element. Add the name attribute to the switch element and provide a value for it.

The error 'ERROR Error: No value accessor for form control with unspecified name attribute on switch' occurs when you are trying to bind a form control to a switch element in Angular. The solution is to provide the name attribute to the switch element.

✅ Best Solutions to Fix It

Method 1: Providing the Name Attribute

  1. Step 1: Add the name attribute to the switch element, like this: <switch [attr.title]="field.etiquette" [attr.value]="field.valeur" [(ngModel)]="field.valeur" [formControl]="fieldControl" [attr.id]="mySwitchName" [attr.disabled]="disabled">

✅ Conclusion

By providing the name attribute to the switch element, you can fix the error and ensure that your form control is bound correctly.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions