Uh-oh! Angular 6 has encountered an unexpected error with template parsing

I am currently working on an Angular application where I have integrated the FormsModule from '@angular/forms' in my app.module.ts. However, despite this, I keep encountering the error message No provider for ControlContainer.

Error log:

Uncaught Error: Template parse errors:
No provider for ControlContainer ("
                <span>Product Catalog</span>
            </h4>
        [ERROR ->]<form [formGroup]="productSearchForm" (ngSubmit)="onSubmit()" class="d-flex md-form justify-content-c"): ng:///ViewsModule/ProductCatalogComponent.html@8:8
No provider for NgControl ("orm" (ngSubmit)="onSubmit()" class="d-flex md-form justify-content-center form-inline">
            [ERROR ->]<select class="custom-select mb-2 mr-sm-2 mb-sm-0" formControlName="f_categoryId">
            <optio"): ng:///ViewsModule/ProductCatalogComponent.html@9:12
No provider for NgControl ("
            </select>

            [ERROR ->]<input type="search" formControlName="f_productDescription" placeholder="Seach the products" aria-lab"): ng:///ViewsModule/ProductCatalogComponent.html@16:12

<!-- Additional template parsing errors go here -->

In my code snippets,

product-catalog.component.html

<div class="card mb-4 wow fadeIn">
    <div class="card-body d-sm-flex justify-content-between">
            <h4 class="mb-sm-0 pt-3">
                <span>Product Catalog</span>
            </h4>
        <form [formGroup]="productSearchForm" (ngSubmit)="onSubmit()" class="d-flex md-form justify-content-center form-inline">
            <select class="custom-select mb-2 mr-sm-2 mb-sm-0" formControlName="f_categoryId">
            <option selected>Choose Category</option>
            <option value="1">One</option>
            <option value="2">Two</option>
            <option value="3">Three</option>
            </select>

            <input type="search" formControlName="f_productDescription" placeholder="Seach the products" aria-label="Search" class="form-control">      
            <button type="submit" class="btn btn-primary"> <i class="fa fa-search"></i></button>
        </form>
    </div>
</div>

product-catalog.component.ts

import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { InventoryService } from '../../_services/inventory.service';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ProductView } from '../../_models/product-view';
import { Category } from '../../_models/category';
import { OrderService } from '../../_services/order.service';

// TypeScript component logic goes here

view.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

// Other module imports and declarations go here

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';

// Main AppModule configuration and setup 

If anyone can assist me with resolving this issue, it would be greatly appreciated. Thank you!

Answer №1

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

inside the view.module.ts file

Answer №2

Don't use FormsModule, use ReactiveFormsModule.

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

Why does my Javascript cross-domain web request keep failing with a Status=0 error code?

UPDATE: I've been informed that this method doesn't work because craigslist doesn't have an Allow-Cross-Domain header set. Fair point. Is there an alternative way to download a page cross-domain using Javascript in Firefox? It's worth ...

``Is there a specific location where I can access the Microsoft Azure msal sign-up feature within Angular

My current Angular version is 5.2.0 and I am struggling to find a tutorial on how to incorporate Azure MSAL for new user sign-up using a Microsoft account. If anyone has any resources or examples on how to achieve this integration without having to update ...

challenges surrounding the use of getElementByTagName

Within my webpage, I have implemented two select elements, both containing multiple options. However, I am facing an issue where I can only access the options from the first select box using getElementByTagName("options"), and unable to retrieve the option ...

"Assigning an array as a value to an object key when detecting duplicates in a

Let's assume the table I'm iterating through looks like this: https://i.stack.imgur.com/HAPrJ.png I want to convert each unique value in the second column into an object, where one of the keys will hold all values from corresponding rows. Here& ...

Change the background color of a table cell based on its value with the help of JavaScript

I am attempting to apply color to cells in an HTML table (generated automatically by Python and Django) based on the content of the cells. Below is my table. I want to specifically color the column "status". Whenever the word "Cloture" appears, I would li ...

Using AJAX for uploading files upon a change event rather than upon submission

Below is the code I have been using to implement an iframe for ajax file upload without refreshing the page upon form submission. The current code works as expected. window.onload=init; function init() { document.getElementById('form').onsubmi ...

When executing `npm run start`, a blank page appears exclusively on the server

I recently set up a Vue landing page on my Mac. In the terminal, I navigated to the folder and executed "npm install" and "npm run dev", which ran without any issues. However, when trying to do the same on a managed server, I encountered challenges with t ...

What is the most effective method for displaying an error code when a JavaScript error occurs?

I'm currently dealing with a library that is throwing errors: throw new Error('The connection timed out waiting for a response') This library has the potential to throw errors for various reasons, making it challenging for users to handle ...

Setting default parameters for TypeScript generics

Let's say I define a function like this: const myFunc = <T, > (data: T) => { return data?.map((d) => ({name: d.name}) } The TypeScript compiler throws an error saying: Property 'name' does not exist on type 'T', whic ...

Every time I hover, my jQuery code keeps repeating the hover effect

I am currently facing an issue that has me stumped on finding a solution. The problem arises when I hover over the .div multiple times, the animation just doesn't stop and keeps running continuously. What I aim for is to have the .hidden element fad ...

Strategies for setting the output value for a defined generic type

Is there a way to create a function that accepts optional properties common across different types, while also requiring specific properties based on the generic type passed in? type Diff<T, U> = T extends U ? never : T type DiffTypes<T, U> = ...

Discover the process of utilizing doc.getElementbyClassName to determine if any of its elements are blank

On my HTML invoice table, I sometimes have empty elements that cause the row to misalign. To fix this, I want to add whitespace if an element is empty. Here is the structure of the table: <div class="invoiceTable"> <div class="titles2" style=" ...

Deleting Firestore ancestor documents and sub-collections that do not exist

My goal is to tidy up my collection data. The collection I'm working with is named "teams". Within this collection, there is a sub-collection called "players". I used a basic delete query in Firestore to remove the document under ...

Loading jQuery on document ready with an Ajax request can lead to slow loading times

My current project involves a significant number of ajax requests being made on document.ready. Additionally, I have ajax requests for every database transaction. These requests are all managed in a JS file, with each ajax request corresponding to a PHP pa ...

Function `getEventMap` that retrieves the specific "EventMap" associated with an EventTarget T

In the file lib.dom.d.ts, there is a defined interface: interface EventTarget { addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void; dispatchEvent(event: Event): boo ...

How to dynamically inject HTML content from a child component into a different component using Angular 5

Is it possible to customize the content of a reusable header section based on the current route data in Angular? The header currently displays a title and description pulled from the route data property. My concern is how to dynamically inject different H ...

When attempting to render mathML in a canvas on Safari, the image load callback does not properly trigger, resulting in

I am currently working on rendering mathML into an HTML5 canvas. One suggestion I received was to embed the mathML as an SVG foreign object, render it into an image, and then display the image within the canvas. However, this method works fine in Firefox ...

Error encountered when attempting to create an index in ElasticSearch due to

I am encountering an issue with the elasticsearch npm module while attempting to create an Index, resulting in a TypeError with the following message: Unable to build a path with those params. Supply at least index The code snippet I am using is as follo ...

Implement a customized toString method for components in ReactJS

Looking to modify the toString method of a class component in reactjs? Check out the code snippet below class C1 extends React.Component{ render(){ return ( <div> {C2.toString()} </div> ) } } class C2 extend ...

When working with Angular and either Jasmine or Karma, you might encounter the error message: "Unexpected state: Unable to retrieve the summary for the

I've been struggling to fix this error and so far, nothing I find online is helping... lr-categories.component.spec.ts: export function main() { describe('LrCategoriesComponent', () => { let fixture: ComponentFixture<LrCategori ...