Angular: NG8003: No directive found with exportAs 'ngForm' (template reference variable)
A template reference such as #f="ngForm" points at a directive Angular cannot find on that element — the module that provides it is not imported.
No directive found with exportAsNo directive found with exportAs 'ngForm'No directive found with exportAs 'ngModel'Export of name 'ngForm' not found Meaning
#ref="name" asks for the directive whose exportAs is that name. If FormsModule, ReactiveFormsModule or the Material module that exports it is not imported, there is no directive with that name. Fix the import, not the template.
Common causes
FormsModulemissing for#f="ngForm"or#c="ngModel"ReactiveFormsModulemissing forformGroupreferences- Material directive module not imported (for example
MatMenuModulefor#menu="matMenu") - Directive not applied on that element (typo in its selector)
- Standalone component forgot the directive in
imports
⚡ Quick fix
- Import
FormsModule(or the module/directive that provides the exportAs) - Check that the directive's selector actually matches the element
- Open the library docs for the exact
exportAsname
Detailed fix by platform
Angular
- Standalone:
imports: [FormsModule] - NgModule: add
FormsModuleto theimportsof the module that declares the component
Code examples
Template reference with exportAs
<form #f="ngForm" (ngSubmit)="save(f.value)"> <!-- needs FormsModule -->
<input name="email" ngModel required>
<button [disabled]="f.invalid">Save</button>
</form>How to diagnose
- Name — Which exportAs is requested?
- Imports — Is the providing module imported here?
- Element — Does the directive attach to this element?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Cannot find control with name Angular: Error: Cannot find control with name: 'email' (reactive forms)
- mat-form-field must contain a MatFormFieldControl Angular Material: Error: mat-form-field must contain a MatFormFieldControl
- NG01050 Angular: NG01050: formControlName must be used with a parent formGroup directive
Most viewed in Angular
- NullInjectorError Angular: NullInjectorError: No provider for X!
- NG0100 Angular: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
- NullInjectorError: No provider for HttpClient! Angular: NullInjectorError: No provider for HttpClient! — provideHttpClient() missing
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026