1

I have imported both FormsModule, and ReactiveFormsModule in my app.module, html should be correct hopefully,

error

import

**Inside app.module:**
@NgModule( 
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ReactiveFormsModule,
RouterModule.forRoot(ROUTES, { useHash: true })
],
})



**My HTML:**
<div class="col-xs-12">
<input #searchTextBox type="text" class="validate filter-input" [(ngModel)]="query" (keyup)="onKeyup(searchTextBox.value)">
  <div class="suggestions" *ngIf="filteredList.length > 0">
    <ul *ngFor="let item of filteredList">
      <li>
        <a (click)="select(item)">{{item}}</a>
      </li>
    </ul>
  </div>

I get this error when i run npm run test:local, but it runs fine if I do npm start. I use multiple [(ngModel)] and they all have this same problem, I am just using this one for example.

How can I fix this?

H.ALL
  • 11
  • 2
  • 1
    Import `FormsModule` in `DynamicTestModule` – yurzui Jun 27 '17 at 19:31
  • 1
    Possible duplicate of [Angular 2: Can't bind to 'ngModel' since it isn't a known property of 'input'](https://stackoverflow.com/questions/38880150/angular-2-cant-bind-to-ngmodel-since-it-isnt-a-known-property-of-input) – developer033 Jun 27 '17 at 20:09

1 Answers1

0

We were facing the same issue and just importing the FormsModule did not work. Use this tag where it errors out - [ngModelOptions]="{standalone: true}"

Adding the following to your .component.html can do the trick as it did for us on Login screen -

Example:

<input [(ngModel)]='this.userId' [ngModelOptions]="{standalone: true}" placeholder="User Id" class="inputstyle">
Vivz
  • 6,625
  • 2
  • 17
  • 33