• Register
0 votes
82 views

Problem :

I am facing below error when trying to launch my Angular app, even if my component is not displayed at all.

Can't bind to 'ngmodel' since it isn't a known property of 'input'. ("

 How can I fix this issue?

8 4 2
2,300 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had faced this issue while writing my first code in Angular App. The solution is easy just follow below procedure.

Lets assume that you are creating the  new NgModule, say some AuthModule which is dedicated towards handling all your Auth needs, then you must import FormsModule in your AuthModule too.

If you want to use the FormsModule only in your AuthModule then you dont need to import your FormModule in your default AppModule

So write below code in your AuthModule:

import { NgModule }      from '@angular/core';
import { FormsModule } from '@angular/forms';
import { authRouting } from './auth.routing';
import { LoginComponent, SignupComponent } from './auth.component';

@NgModule({
  imports:      [ 
    authRouting,
    FormsModule
   ],
  declarations: [ 
    SignupComponent,
    LoginComponent
  ]
})
export class AuthModule { }

Then just forget about the importing in the AppModule if you don't want to use your FormsModule anywhere else.

If you want to use the two-way data binding for the form inputs then you need to import your FormsModule package in the Angular module.

5 2 1
4,980 points

Related questions

0 votes
1 answer 1.9K views
1.9K views
Problem : I am beginner in using Angular material. I am trying to use autocomplete component in the Angular2 project. Please find below the code written for my component. import {Component, OnInit} from "@angular/core"; import {ActivatedRoute, Router} from "@angular/router"; ... ; I am struggling with this issue from past 2 days but unable to resolve it. Can somebody help me in fixing this issue?
asked Feb 27, 2020 mphil 2.3k points
1 vote
2 answers 153 views
153 views
Problem : I am beginner to Angular2. Currently I am trying to create a simple form in the Angular2 app but it is not working for me. I am facing below error. “Can't bind to 'formGroup' since it isn't a known property of 'form'.” I am struggling on this error from couple of days. Still I don’t know how to fix above error. Is it possible for somebody to fix it for me?
asked Mar 27, 2020 morrisBson 3.2k points
0 votes
0 answers 4 views
4 views
Problem: I have the following error when starting my angular application, even if the component is not showing. I have to comment on the way my app works. zone.js:461 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngModel' since it ... /details/intervention.details.css'] }) export class InterventionDetails { @Input() intervention: Intervention; public test : string = "toto"; }
asked 1 day ago sasha 12.9k points
0 votes
1 answer 3.4K views
3.4K views
Problem: I am beginner to Angular. I have recently started working in Angular project but I am facing below bizarre error: &ldquo;Can't bind to 'ngIf' since it isn't a known property of 'div'.&rdquo; The element is I guess <div [ngIf]="isAuth" id="sidebar ... is the child component. In my parent component i.e. App component the ngif works properly. Please Note: I am currently using Angular RC5.
asked Aug 17, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 431 views
431 views
Problem : I am very new to Angular2. Currently I am trying to create the component after that it is set to the root component but still I am facing below error: Template parse errors: Can't bind to 'routerLink' since it isn't a known property of 'a'. I ... days on researching and trying to fix above error but unable to fix it so now I need Angular2 experts advice to quick fix my Angular2 error.
asked May 2, 2020 stewart 4k points
0 votes
1 answer 140 views
140 views
Problem: I am naive to Angular, Webpack, Bootstrap and typescript. I have tried to write a service but it is throwing the below error while my app is bootstrapping. I am currently using ng2 2.4.2 and the angular-cli 1.0.0-beta.24. My TypeError as below: &ldquo;Uncaught typeerror: ... .navigate(['/project', query]); } public extractData(res: Response) { let body = res.json(); return body || {}; } }
asked Sep 3, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 3.6K views
3.6K views
Problem: I am currently wondering why I am getting below compile error if I just declare variable with var or let keywords? I want to say, below code goes well: export class MyAppComponent { myRefreshClickStream$: any; constructor(){ } } While this brings the error: export class MyAppComponent { var myRefreshClickStream$: any; constructor(){ } }
asked Jan 27, 2020 jwilliam 3.9k points
1 vote
2 answers 4.9K views
4.9K views
Problem : I have recently started learning Angular2. I am trying to create the component but I am facing below error. &ldquo;Is an angular component, then verify that it is part of this module.&rdquo; KIndly find below my code for your reference. import { Component } from ' ... : ` <p>This is my Hello World article</p> ` }) export class MyHelloComponent { } Kindly help me in fixing above error.
asked Mar 30, 2020 morrisBson 3.2k points
0 votes
1 answer 137 views
137 views
Problem: I am getting following message when i run angualr2 program with typescript. angular is running in the development mode. call enableprodmode() to enable the production mode. What is the reason for this message is it a deployment option? Curious for feedback ?
asked Jul 16, 2020 quizzBabes 160 points
0 votes
1 answer 822 views
822 views
Problem : I am facing below error as : node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected. After I tried to do the installation of Angular 6. Check the detailed error as below : ERROR in node_modules/rxjs/internal/types.d.ts(81,44): ... internal/types.d.ts(81,76): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,78): error TS1109: Expression expected.
asked Dec 18, 2019 alecxe 7.5k points