Issue: Unable to link to 'FormGroup' because it is not recognized as a valid property of 'form'

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {AppRoutes} from './app.routing';
import { AppComponent } from './app.component';
import {ReactiveFormsModule,FormsModule} from "@angular/forms";

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forRoot(AppRoutes),
    BrowserModule
  ],
  declarations: [
    AppComponent,
  ],
  providers: [
    customHttpProvider(),
    AccessService,
    RouteAccessService,
    JwtHelperService

  ],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }

issue encountered:

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'formGroup' since it isn't a known property of 'form'.

HTML snippet causing the error

<form [formGroup]="multi1Form">
        <div class="app-modal-header" data-backdrop="static" data-keyboard="false">
           <h4 class="modal-title">Modal 1</h4>
           <button type="button" class="close basic-close" (click)="modalMulti1.hide()">
           <span aria-hidden="true">&times;</span>
           </button>
        </div>
        <div class="app-modal-body" data-backdrop="static" data-keyboard="false">
           <div class="row">
              <div class="col-sm-12">
                 <h4 class="sub-title">First Name</h4>
                 <!-- <form> -->
                 <div class="form-group row">
                    <div class="col-sm-12">
                       <input class="form-control form-control-md" formControlName="fname" [(ngModel)]="item.fname"  placeholder="First name" type="text">
                    </div>
                 </div>
                 <!-- </form> -->
              </div>
              <div class="col-sm-12">
                 <h4 class="sub-title">Last Name</h4>
                 <!-- <form> -->
                 <div class="form-group row">
                    <div class="col-sm-12">
                       <input class="form-control form-control-md" formControlName="lname" [(ngModel)]="item.lname"  placeholder="Last name" type="text">
                    </div>
                 </div>
                 <!-- </form> -->
              </div>              
           </div>
        </div>
        <div class="app-modal-footer">
           <button type="button" class="btn btn-default waves-effect " (click)="modalMulti1.hide()">Close</button>
           <button data-toggle="modal" [disabled]='!multi1Form.valid' (click)="modalMulti2.show(); modalMulti1.hide();" class="btn btn-primary waves-effect waves-light">Next</button>
        </div>
     </form>

component.ts

import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
import {ToastData, ToastOptions, ToastyService} from 'ng2-toasty';
import {transition, trigger, style, animate} from '@angular/animations';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import swal from 'sweetalert2';

@Component({
  selector: 'app-popup-validation-wizard',
  templateUrl: './popup-validation-wizard.component.html',
  styleUrls: ['./popup-validation-wizard.component.css',
  '../../../../../node_modules/ng2-toasty/style-default.css',
  '../../../../../node_modules/ng2-toasty/style-material.css',
  '../../../../../node_modules/ng2-toasty/style-bootstrap.css',],
  encapsulation: ViewEncapsulation.None,
})

export class PopupValidationWizardComponent implements OnInit {

  multi1Form: FormGroup;

  constructor() {}

  ngOnInit() {
    this.checkForm();
  }

  private checkForm() {
    this.multi1Form = new FormGroup({
      fname: new FormControl('Asif', [Validators.required, Validators.minLength(2), Validators.maxLength(15)]),
      lname: new FormControl('', [Validators.required, Validators.minLength(2), Validators.maxLength(15)]),
    });
  }
}

I have already imported FormsModule in my app.module.ts file but the error persists in the console. I am unable to navigate to the HTML page where the issue is occurring. Is there a solution for this problem? Alternatively, what other approach can be taken to resolve this issue considering that I am currently using Angular 4 and TypeScript 2.x?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

NGINX returns 404 error when attempting to access Angular application with data in the URL

My server setup includes the following: At the root (/var/www) directory, there is an index.html file that connects to two Angular applications - app1 and app2 \index.html | +-\app1\index.html | +-\app2\index.html ...

Enhancing user experience by highlighting invalid input fields with a red border using client-side HTML5 validation and Bootstrap 5.2

When reviewing the Bootstrap 5.2 validation documentation, https://getbootstrap.com/docs/5.2/forms/validation/ "It has come to our attention that the client-side custom validation styles and tooltips are not accessible at this time, as they are not ...

Creating Angular Components Dynamically through API Requests

Generating Component Template and Typescript Code Dynamically I am attempting to dynamically create a component where an HTTP service call provides us with the HTML template and Typescript code. While we can set the HTML template dynamically, I am facing ...

Pause code execution and prompt user interaction within a loop - React

I have been working on adding an "add all" button to my React app. To achieve this, I am passing a function to the onClick method of the button: for (element in elements) { await uploadfunction(element) } const uploadfunction = async (element) => ...

Some files are missing when performing an npm install for a local package

My project is structured like this: ├── functions/ │ ├── src │ ├── lib │ ├── package.json ├── shared/ │ ├── src │ | ├── index.ts | | ├── interfaces.ts | | └── validator_cl ...

Achieve SEO excellence with Angular 4 in production settings

I am currently building a website using Angular 4 as part of my personal study project. Although my website is live, I realized that it's not SEO friendly. After making some changes, I came across a valuable resource on server-side rendering in Angul ...

Component loader with dynamic rendering for multiple components

Currently, I am in search of a method to dynamically render components within my Angular application. While exploring various options, I came across the concept of dynamic component loading in Angular (refer to https://angular.io/guide/dynamic-component-lo ...

Implementing a click event to convert text to input in Angular 5

I'm struggling with setting values instead of just getting them. I want to switch from using divs to input fields and update the values when in "editMode". <div class="geim__sets"> <div *ngFor="let set of game.sets" class="geim__set"> ...

The RxDB Angular2-cli error message. "Cannot assign a 'Promise<void>' to a 'Promise<any>' parameter."

I've been grappling with getting RxDB to function properly in a fresh project I initiated using the Angular CLI. Here's my process: ng new <Projectname> After that, I installed RxDB by running: npm install rxdb Following the example p ...

Save solely the timing information in Mongodb

Looking for advice on storing time values in MongoDB? Users will be inputting times as strings, such as "05:20", and you need to convert and store this data correctly. Any suggestions on how to achieve this? I've attempted using the Date object with ...

What is the best way to implement a dynamic mask using imask in a React

I have a question regarding the implementation of two masks based on the number of digits. While visually they work correctly, when I submit the form, the first mask is always selected. How can I resolve this issue? My solution involves using imask-react ...

Guide on Retrieving an Array from an Observable

Hey there! I've come across a function that is supposed to return an Array. In the function below, this.cordovaFile.readAsArrayBuffer(this.cordovaFile.dataDirectory, storageId) actually returns a Promise Array. I'm converting it into an Observabl ...

Leveraging the power of NestJS in conjunction with Apollo Server version 2

I recently delved into learning nestjs and decided to give this graphql example a try. The issue I encountered is that the example was originally designed for apollo-server version 1, and I'm having difficulty adapting it to work with apollo-server v ...

Comparing tsconfig.json and tsconfig.build.json: what sets them apart?

Guides like those found at 1 and 2 often recommend having two separate files - tsconfig.json and tsconfig.build.json - at the root level of an NPM monorepo for TypeScript projects. What are the distinctions between these files? Is it possible to consolida ...

What is the most effective way to split time into two separate parts?

Suppose a user enters the time as 12:34 and we need to split it into two different parts to save it in an array like [12, 34]. How can this be achieved using Angular? I attempted to split them but my solutions were unsuccessful! I am currently utilizing & ...

What causes me to create components with incorrect paths?

Can someone assist me with creating a new component in the dynamic-print folder instead of it being created in the app? Thank you ...

Angular2 combined with redux fails to produce any outcomes

Currently, I am implementing redux in conjunction with angular2 and attempting to make a call to Windows Azure Search. Below is the snippet of code that I have written: types.ts export interface IAppState { languageState?: LanguageState; searchState? ...

Issue encountered during Imgur upload due to an incorrectly formatted authentication header

I'm having trouble utilizing Imgur to upload images within an angular web app, as I keep encountering the error message "Malformed auth header". Does anyone have a solution to rectify this issue? async uploadImage(imageFile: File, infoObject: {}, c ...

What is the process of organizing information with http in Angular 2?

Currently, I am working through a heroes tutorial and have made progress with the code so far. You can view the code <a href="https://plnkr.co/edit/YHzyzm6ZXt4ESr76mNuB?preview" rel="nofollow noreferrer">here</a>. My next goal is to implement ...

Attempting HTTP requests on an iOS simulated device using Ionic Capacitor is not functioning properly

Upon sending an HTTP request, it functions smoothly on the browser (using Ionic serve). However, when I compile IOS and Android versions using Capacitor, I encounter the error displayed in the console: Error: SyntaxError: JSON Parse error: Unrecognized tok ...