Angular Error: "There is no directive with exportAs set to ngForm" when working with forms
Hello everyone! I'm new to Angular and TypeScript, and I've been struggling for hours with an error that occurs when trying to use template-driven forms.
I have a simple component for user registration. I created a form with two fields: email and password. I'm using the `ngModel` directive for two-way data binding and want to access the form through a local variable `#myForm="ngForm"`. Here's my code:
**user-registration.component.ts:**
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-user-registration',
templateUrl: './user-registration.component.html',
styleUrls: ['./user-registration.component.css']
})
export class UserRegistrationComponent {
user = {
email: '',
password: ''
};
onSubmit() {
consol
No answers yet.
Log in to leave an answer
Blogs
Functional Programming in Swift: Advanced Level
How to Get the Current URL via JavaScript: An Under the Hood Breakdown
Creating Excel in C# without Microsoft Office: Magic Under the Hood
Rust on LeetCode: Solving Problems and Leveling Up Your Skills