core.js:12853 Error encountered when trying to use 'ngIf' on a 'div' element that is not recognized as a valid property

I am currently utilizing Angular 9.

and I am faced with a scenario where I need to load dynamic components

Within one of my components, I encountered the following warning

core.js:12853 Can't bind to 'ngIf' since it isn't a known property of 'div'

I have already imported commonModule in my app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'
import { HTTP_INTERCEPTORS } from '@angular/common/http';

import { CommonModule } from '@angular/common';

// Module imports
import { ServeMonstaAuthenticationRoutingModule } from './serve-monsta-authentication/serve-monsta-authentication-routing.module'
import { ServeMonstaAuthenticationModule } from './serve-monsta-authentication/serve-monsta-authentication.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
// Services imports
import { UserLoginService } from './serve-monsta-authentication/services/user-login/user-login.service';
import { UserSignupService } from './serve-monsta-authentication/services/user-signup/user-signup.service';
import { SurveyService } from '../services/survey/survey.service';

// Component imports
// Add your component imports here

@NgModule({
  declarations: [
    // Add your component declarations here
  ],
  imports: [
    BrowserModule,
    CommonModule,
    FormsModule,
    AppRoutingModule,
    ServeMonstaAuthenticationModule,
    ServeMonstaAuthenticationRoutingModule,
    BrowserAnimationsModule,
    RouterModule,
    BsDatepickerModule.forRoot(),
  ],

  entryComponents:[
    // Add your entry components here
  ],
  providers: [
    // Add your providers here
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Below is the component where I am using ngIf

import { Component, OnInit } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { Field } from '../../../core/question/field';
import { FormGroup } from '@angular/forms';

@Component({
  selector: 'app-radio',
  template: `
    <!-- Your template code goes here -->
  `,
  styles: [],
})
export class RadioComponent implements OnInit {
  field: Field;
  group: FormGroup;

  constructor() {}

  ngOnInit(): void {
    console.log("Hey I am Radio :: ", this.field)
  }
}

Here is the object(response) received in the above component

// Your response object details go here

If you have any suggestions, please feel free to share. I have already included CommonModule and tried using an extra boolean variable, but the issue persists.

Answer №1

In the event that you are incorporating a personalized module, it is imperative to also bring in the Common Module. By taking this step, it is anticipated that the problem at hand will be rectified.

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

Ways to generate an Angular 7 component

Seeking guidance on creating an angular 7 component. I have forked a jsFiddle at this link: https://jsfiddle.net/gauravshrestha/fdxsywLv/. The chart in the fiddle allows data points to be dragged up and down. My goal is to convert this into a component whe ...

Error encountered in Typescript when handling fetch options as a variable

Why does this code compile perfectly? fetch('someurl', { method: 'GET', credentials:"same-origin" }) However, the following code throws a compilation error for fetch('someurl', init); const init = { method: &apo ...

``I am encountering an issue where the highlighted color of a textbox is not being

In my MVC3 view page, I have a password control with an onblur function being called from the control itself: @Html.PasswordFor(m => m.CurrentPass, new Dictionary<string, object> { { "id", "txtCurrentPass" }, { "name", "CurrentPass" }, { "Class", ...

Removing items from a JavaScript list

I am seeking assistance with an issue I am facing. I have a function that generates a list based on user inputs. For instance, when a user enters apples, the function adds it to a <ul> list. My concern is about deleting specific inputs from the lis ...

Utilize Vue.js methods to reverse the string within a paragraph using the appropriate function

Hello everyone, I've been attempting to implement a function to reverse a string within a paragraph text in vue.js. I've created a method called reverseword to reverse the words and added it to a card using :rule="reverseword()", but un ...

Troubleshooting TypeScript Modules in Visual Studio 2015 Update 2: Fixing the 'require' Undefined Error

While working in Visual Studio 2015 Enterprise with Update 2 installed, I decided to create a new TypeScript project called TypeScriptHTMLApp1 using the default template and settings. As part of this project, I added a new TypeScript file named log.ts and ...

Improving iframe functionality in AngularJS

I've been experimenting with AngularJS to dynamically update an iframe whenever a query is triggered. It works like this: a query is made, the embed link is fetched from the database, and then it's used in the iframe alongside the title and video ...

What are your thoughts on combining a JSON object with HTML?

When using ASP.NET MVC, it is possible to return a JSONResult. return JSON(new { View = RenderViewAsString("MyView", model), wasSuccessful = true}) This approach combines HTML and data in a single JSON object. The goal is to utilize strongly typed HtmlHe ...

Tips for making a React/Socket.IO app accessible from external sources

Trying to get my React app (built with Node.js and Socket.IO) running locally and accessible from external sources has been a challenge for me. I've managed to expose port 3000 using ngrok tunneling, but my socket connection is listening on port 3001. ...

The Socket IO server fails to broadcast a message to a designated custom room

I am currently working on developing a lobby system that allows players to invite each other using Socket io version 4. The process involves the client sending a request to create and join a room, followed by emitting messages to other clients in the same ...

Discrepancy in Angular Material Buttons with theme design

I recently installed Angular 10 along with Angular Materials using the command ng add @angular/material I opted for the custom theme: Purple/Green The next step was to add a Toolbar by simply copying and pasting code from Google's site. However, I a ...

Is there a way to postpone the mouseover event for vertical tabs?

While this may seem like a simple question to some, my programming skills are not quite up to par. I am seeking help from someone who can assist me. My goal is to delay the mouseover event on vertical tabs so that users can jump directly from tab 1 to ta ...

Incorporate the block-input feature from sanity.io into your next.js blog for enhanced functionality

Currently, I'm in the process of creating a blog using next.js with sanity.io platform. However, I am facing some difficulties when it comes to utilizing the code-input plugin. What's working: I have successfully implemented the code component b ...

What is the best way to define a function that accepts an object with a specific key, while also allowing for any additional keys to be passed

Typescript allows us to define an interface for an object that must have a key and can also allow additional keys: interface ObjectWithTrace { trace: string; [index: string]: any } const traced: ObjectWithTrace = { trace: 'x', foo: 'bar ...

Is there a way to prevent TypeScript from flagging static members on a function as errors?

In my example, I have outlined the issue at hand. Essentially, I am seeking to comprehend the proper way to write valid TypeScript code when adding static members to a function in the following code snippet: export const ZoomPanelControl = (props) => ...

how can I use jQuery to disable clickable behavior in HTML anchor tags?

Here is the HTML code I am working with: (note -: I included j library on the top of page ) <div class="WIWC_T1"> <a href="javascript:void(0);" onClick="call_levelofcourse();popup('popUpDiv1')">Level of Course</a> </di ...

What is the correct way to invoke a function from an external JavaScript file using TypeScript?

We are currently experimenting with incorporating Typescript and Webpack into our existing AngularJS project. While I have managed to generate the webpack bundle, we are facing an issue at runtime where the program is unable to locate certain functions in ...

Tips for passing a value or argument to the map function in JavaScript

Can someone guide me on how to pass a variable in the map function using JavaScript? const obj = ["Singapore", "Malaysia"] const pr = ["SG", "MY"] // need to pass value to map function render(){ obj.map((val, index) => { return html` <p ...

Step-by-step guide on incorporating a climate clock widget into your Angular project

Is there a way to integrate the Climate Clock widget from into my Angular project? Upon adding the following code snippet: <script src="https://climateclock.world/widget-v2.js" async></script> <script src="https://climateclo ...

Personalizing the React Bootstrap date picker

I am currently working on customizing the react-bootstrap-daterangepicker to achieve a specific look: My goal is to have distinct background colors for when dates are selected within a range and when the user is hovering over dates to make a selection. I ...